This patch is a part of attempt to standardize code motion checks into one place. LoopFuse already uses CodeMoverUtils. This is a work in progress until we move all generic code motion checks into CodeMoverUtils. We started with moving less aggressive checks from LICM to CodeMoverUtils which can also be used by other code motion clients.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/Analysis/LoopAnalysisManager.h | ||
---|---|---|
63 ↗ | (On Diff #272400) | Requiring those extra analysis here requires a strong motivation I think, as I think each loop pass has to make sure they are preserved or recomputed. |
llvm/lib/Transforms/Scalar/LICM.cpp | ||
1380 | In order to make the transition to more general utils easier I think it might be worth considering making PDT/DI optional in the various utils and separate it from making DI & PDT required for all users, which potentially has quite a big impact. Also, I think LICM already uses MemorySSA to figure out if it is legal to move memory access out of the loop. |
Thank you for the patch!
This needs to be split up into multiple changes, there's too much going on in this patch to review as is.
Cleaning up the utilities, adding const, clang-format are all awesome and straight-forward to review. They should be separate NFCs.
Adding those dependencies (PDT and DepAnalysis) are not correct in this format, in particular in the loop pass manager. The implication there is that *all* loop passes in *any* loop pipeline are guaranteed to preserve those analyses. At least for PDT, I know that's not the case. I'm not familiar with DepAnalysis, but it looks like its scope overlaps with MemorySSA.
The constraints are different for Loop vs Function passes (LICM is a loop pass, LoopVectorize is a function pass), so again, the changes need to be reviewed separately.
llvm/include/llvm/Analysis/LoopAnalysisManager.h | ||
---|---|---|
48 ↗ | (On Diff #272400) | nit: follow alphabetic order. |
163 ↗ | (On Diff #272400) | recommend not to do formatting changes on lines not changed by you. |
llvm/lib/Transforms/Scalar/LICM.cpp | ||
255 | Can you please elaborate what you mean by deep changes? Do you mean adding adding PDT and DI in AR? |
llvm/lib/Transforms/Scalar/LICM.cpp | ||
---|---|---|
255 | Thanks, yes, I was referring to all the side effect changes that are required because of adding PDT and DI in AR. MSSA checks look really promising I was planning to get them in. |
The issue with this change is that there is a lot of unnecessary work done now. Before, we could exit early to decide an instruction could never be hoisted/sunk. Now, we're removing all those early checks and only when actually trying to move get the "actually, you can't". I expect this to get a big compile-time penalty.
Could you do some testing and include results in the patch summary?
Totally agreed with the delayed check issue and I've moved it to a place that is more analogous to the original checks. LICM has very extensive code motion checks, moving the generalized checks to a unified place will greatly help other passes to take advantage of them. Does the updated diff look satisfactory to you?
Yes, the diff look good. Could you clarify what isSafeToMove does? I don't see it in the included file, only isSafeToMoveBefore. Is there a dependent patch not linked?
@Whitney I'm not sure is it okay to do all these deep changes but they all exist because this LICM invocation requires analysis from AnalysisResult. I request your comment on this.