[llvm] [LoopRotate] Rotate loop if this makes exit count computable (PR #162654)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 23 06:39:11 PDT 2025
nikic wrote:
To add some more data here, this is the impact of just performing the analysis without actually doing the rotation: https://llvm-compile-time-tracker.com/compare.php?from=5841319aca0f2596cc00ab83d54ec07c9b70da3c&to=d60a14f066e38e572d5266b7526c575c391cf657&stat=instructions%3Au
And this is the impact of doing the rotation: https://llvm-compile-time-tracker.com/compare.php?stat=instructions%3Au&from=d60a14f066e38e572d5266b7526c575c391cf657&to=08496a966850e06788de4bbf75e521ee5ed1363c
So the main cost here is the analysis part. I believe the problem is that LoopRotate is an LPM1 pass, and LPM1 does not use SCEV. All the SCEV based passes are in LPM2. This means we're doing SCEV construction just for LoopRotate.
The heuristic itself does seem pretty sensible to me.
Regarding unrolling specifically, I wonder whether it would make sense to support non-latch runtime unrolling? IIRC the non-runtime unrolling used to be limited to latch exits as well, but I generalized that to arbitrary exits at some point. (I haven't looked whether this is feasible...)
https://github.com/llvm/llvm-project/pull/162654
More information about the llvm-commits
mailing list