[clang] [llvm] [LICM] Sink unused l-invariant loads in preheader. (PR #157559)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 13:40:22 PDT 2025
================
@@ -545,11 +551,18 @@ bool LoopInvariantCodeMotion::runOnLoop(Loop *L, AAResults *AA, LoopInfo *LI,
assert((L->isOutermost() || L->getParentLoop()->isLCSSAForm(*DT)) &&
"Parent loop not left in LCSSA form after LICM!");
+ // sink pre-header defs that are unused in-loop into the unique exit to reduce
+ // pressure.
+ Flags.setIsSink(true);
+ Changed |= sinkUnusedInvariantsFromPreheaderToExit(L, AA, &SafetyInfo, MSSAU,
+ SE, DT, Flags, ORE);
----------------
nikic wrote:
In terms of ordering, I think it would make the most sense to do this between sinkRegion and hoistRegion above.
Anything that gets hoisted out by hoistRegion cannot be sunk, otherwise sinkRegion would have already done it. So there is no need to check the hoisted instructions for sinking again.
https://github.com/llvm/llvm-project/pull/157559
More information about the llvm-commits
mailing list