[llvm] [LoopPeel] LCSSA form is destroyed by LoopPeel, preserve it (PR #78696)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 02:52:51 PST 2024
================
@@ -643,10 +644,22 @@ bool SimplifyIndvar::replaceIVUserWithLoopInvariant(Instruction *I) {
}
auto *Invariant = Rewriter.expandCodeFor(S, I->getType(), IP);
+ bool NeedToEmitLCSSAPhis = false;
+ if (!LI->replacementPreservesLCSSAForm(I, Invariant))
+ NeedToEmitLCSSAPhis = true;
I->replaceAllUsesWith(Invariant);
LLVM_DEBUG(dbgs() << "INDVARS: Replace IV user: " << *I
<< " with loop invariant: " << *S << '\n');
+
+ if (NeedToEmitLCSSAPhis) {
+ SmallVector<Instruction *, 1> NeedsLCSSAPhis;
+ NeedsLCSSAPhis.push_back(dyn_cast<Instruction>(Invariant));
+ formLCSSAForInstructions(NeedsLCSSAPhis, *DT, *LI, SE);
+ LLVM_DEBUG(dbgs() << "INDVARS: replacement of IV user: " << *I
+ << " with loop invariant: " << *S
----------------
nikic wrote:
This part of the message will be duplicated with the debug output above. I'd leave it off.
https://github.com/llvm/llvm-project/pull/78696
More information about the llvm-commits
mailing list