[llvm] [LSR][RFC] Improve LCSSA preservation ? (PR #185373)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 11 15:42:45 PDT 2026
boomanaiden154 wrote:
> My 2c is that the hard LCSSA requirement for loop passes that the NPM introduced was probably a mistake. Not all loop passes actually benefit from LCSSA, and I think for LSR in particular it's probably even detrimental, because it obscures out-of-loop users.
I think the main thing that pretty much every loop pass is going to get out of LCSSA is better SCEV results. Looking at some of the test differences, it seems like we are getting improvements due to what I presume (although I might be missing something) is better SCEV within loop nests given LoopStrengthReduce doesn't use `getSCEVAtScope`. For examples, see e.g., `llvm/test/Transforms/LoopStrengthReduce/X86/lsr-overflow.ll` or `llvm/test/Analysis/ScalarEvolution/pr62430.ll`. I hadn't thought of LCSSA obscuring out-of-loop users, which is a good point. I think we could go two different ways: use `getSCEVAtScope` and not require LCSSA, or if we see optimization regressions due to out of loop users being obscured, we should be able to make the pass/analyses look through trivial phi nodes. I think the latter would be simpler (although I might be massively underestimating the effort there).
>From a cursory glance at the tests, it also doesn't seem like there are any regressions related to obscured live-outs.
https://github.com/llvm/llvm-project/pull/185373
More information about the llvm-commits
mailing list