[llvm] [VPlan] Account for early-exit dispatch blocks when updating LI. (PR #185618)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 08:25:45 PDT 2026
================
@@ -390,22 +390,40 @@ BasicBlock *VPBasicBlock::createEmptyBasicBlock(VPTransformState &State) {
return NewBB;
}
+/// Determine the parent loop for \p VPBB by checking if it is an exit block
+/// or if all of its successors lead to exit blocks (following single-successor
+/// chains). Returns the innermost loop containing any of the exits if all
+/// paths lead to exits, or \p DefaultLoop otherwise.
+static Loop *getParentLoopForBlock(VPBlockBase *VPBB, VPlan &Plan, LoopInfo &LI,
+ Loop *DefaultLoop) {
+ Loop *ParentLoop = nullptr;
+ for (VPBlockBase *Succ : VPBB->getSuccessors()) {
+ while (Succ && !Plan.isExitBlock(Succ))
+ Succ = Succ->getSingleSuccessor();
----------------
david-arm wrote:
It would be good to explain the logic behind this. Why is it that a block without a single successor (could be a block with > 1 successor or a block with no successors) can use the `DefaultLoop`?
It may be correct, but it relies upon the reader having a very deep understanding of the expected VPlan graph at this phase in the set of transformations. And the VPlan CFG does change quite frequently.
https://github.com/llvm/llvm-project/pull/185618
More information about the llvm-commits
mailing list