[llvm] [VPlan] Add BranchOnMultiCond, use for early exit plans. (PR #172750)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 23 14:26:23 PST 2025
================
@@ -3846,36 +3900,36 @@ void VPlanTransforms::handleUncountableEarlyExit(VPBasicBlock *EarlyExitingVPBB,
? CondOfEarlyExitingVPBB
: Builder.createNot(CondOfEarlyExitingVPBB);
- // Split the middle block and have it conditionally branch to the early exit
- // block if CondToEarlyExit.
+ // Create a BranchOnMultiCond in the latch that branches to:
+ // [0] vector.early.exit, [1] middle block, [2] header (continue looping).
VPValue *IsEarlyExitTaken =
Builder.createNaryOp(VPInstruction::AnyOf, {CondToEarlyExit});
- VPBasicBlock *NewMiddle = Plan.createVPBasicBlock("middle.split");
VPBasicBlock *VectorEarlyExitVPBB =
Plan.createVPBasicBlock("vector.early.exit");
- VPBlockUtils::insertOnEdge(LatchVPBB, MiddleVPBB, NewMiddle);
- VPBlockUtils::connectBlocks(NewMiddle, VectorEarlyExitVPBB);
- NewMiddle->swapSuccessors();
+ VectorEarlyExitVPBB->setParent(LatchVPBB->getParent());
+ // Update PHI operands: copy from EarlyExitingVPBB to VectorEarlyExitVPBB.
+ unsigned PredIdx = EarlyExitVPBB->getIndexForPredecessor(EarlyExitingVPBB);
VPBlockUtils::connectBlocks(VectorEarlyExitVPBB, EarlyExitVPBB);
- // Update the exit phis in the early exit block.
- VPBuilder MiddleBuilder(NewMiddle);
VPBuilder EarlyExitB(VectorEarlyExitVPBB);
+ VPBuilder MiddleBuilder(cast<VPBasicBlock>(MiddleVPBB));
----------------
fhahn wrote:
done thanks
https://github.com/llvm/llvm-project/pull/172750
More information about the llvm-commits
mailing list