[llvm] [Transforms][Utils] Handle live-outs not defined in the loop in LoopSplitUtils (PR #214453)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 09:16:12 PDT 2026
================
@@ -364,13 +364,23 @@ void LoopSplitUtils::collectEscapingValues(SplitState &S) {
assert(LCSSAPhi.getNumIncomingValues() == 1 &&
"exit block not in LCSSA form");
Value *LiveOutDef = LCSSAPhi.getIncomingValue(0);
+ LCSSAPhi.replaceAllUsesWith(LiveOutDef);
+ LCSSAPhi.eraseFromParent();
+
+ // A live-out not defined inside the loop (constant or loop-invariant) holds
+ // the same value in every partition, so the replaceAllUsesWith above is
+ // already correct and it needs no per-partition reconstruction. Skipping it
+ // also avoids walking uses() on a constant (which has no use list) and
+ // rewriting any pre-loop uses of an outside definition.
+ auto *DefInst = dyn_cast<Instruction>(LiveOutDef);
+ if (!DefInst || !L->contains(DefInst))
----------------
artagnon wrote:
How can L not contain DefInst?
https://github.com/llvm/llvm-project/pull/214453
More information about the llvm-commits
mailing list