[llvm] [LoopBoundSplit] Fix edge connections during transformation (PR #192106)
Congzhe Cao via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 13:56:12 PDT 2026
================
@@ -356,6 +356,11 @@ static bool splitLoopBound(Loop &L, DominatorTree &DT, LoopInfo &LI,
BasicBlock *PostLoopPreHeader = PostLoop->getLoopPreheader();
IRBuilder<> Builder(&PostLoopPreHeader->front());
+ // Replace exit branch target of pre-loop by post-loop's preheader.
+ if (L.getExitBlock() == ExitingCond.BI->getSuccessor(0))
+ ExitingCond.BI->setSuccessor(0, PostLoopPreHeader);
+ else
+ ExitingCond.BI->setSuccessor(1, PostLoopPreHeader);
----------------
CongzheUalberta wrote:
Thanks, I can add a comment that says something like below:
"Inside LoopInfoBase::verify() it computes another fresh LoopInfo (`OtherLI`) and compare it with the current `LI` for verification. Update the branch here to keep the IR valid in order to correctly compute `OtherLI`, otherwise `OtherLI` would be incorrect which fails the comparison with the current `LI`"
https://github.com/llvm/llvm-project/pull/192106
More information about the llvm-commits
mailing list