[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();
+ if (!Succ)
+ return DefaultLoop;
+ Loop *L = LI.getLoopFor(cast<VPIRBasicBlock>(Succ)->getIRBasicBlock());
+ if (L && (!ParentLoop || ParentLoop->contains(L)))
+ ParentLoop = L;
+ }
+ return ParentLoop;
----------------
david-arm wrote:
Do we expect this to be non-null at this point? If so, might be worth asserting this.
https://github.com/llvm/llvm-project/pull/185618
More information about the llvm-commits
mailing list