@@ -8545,13 +8545,18 @@ static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, bool HasNUW,
8545
8545
static void addUsersInExitBlock (
8546
8546
Loop *OrigLoop, VPRecipeBuilder &Builder, VPlan &Plan,
8547
8547
const MapVector<PHINode *, InductionDescriptor> &Inductions) {
8548
- BasicBlock *ExitBB = OrigLoop->getUniqueExitBlock ();
8549
- BasicBlock *ExitingBB = OrigLoop->getExitingBlock ();
8550
- // Only handle single-exit loops with unique exit blocks for now.
8551
- if (!ExitBB || !ExitBB->getSinglePredecessor () || !ExitingBB)
8548
+ auto MiddleVPBB =
8549
+ cast<VPBasicBlock>(Plan.getVectorLoopRegion ()->getSingleSuccessor ());
8550
+ // No edge from the middle block to the unique exit block has been inserted
8551
+ // and there is nothing to fix from vector loop; phis should have incoming
8552
+ // from scalar loop only.
8553
+ if (MiddleVPBB->getNumSuccessors () != 2 )
8552
8554
return ;
8553
8555
8554
8556
// Introduce VPUsers modeling the exit values.
8557
+ BasicBlock *ExitBB =
8558
+ cast<VPIRBasicBlock>(MiddleVPBB->getSuccessors ()[0 ])->getIRBasicBlock ();
8559
+ BasicBlock *ExitingBB = OrigLoop->getExitingBlock ();
8555
8560
for (PHINode &ExitPhi : ExitBB->phis ()) {
8556
8561
Value *IncomingValue =
8557
8562
ExitPhi.getIncomingValueForBlock (ExitingBB);
@@ -8777,13 +8782,8 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
8777
8782
// After here, VPBB should not be used.
8778
8783
VPBB = nullptr ;
8779
8784
8780
- if (CM.requiresScalarEpilogue (Range)) {
8781
- // No edge from the middle block to the unique exit block has been inserted
8782
- // and there is nothing to fix from vector loop; phis should have incoming
8783
- // from scalar loop only.
8784
- } else
8785
- addUsersInExitBlock (OrigLoop, RecipeBuilder, *Plan,
8786
- Legal->getInductionVars ());
8785
+ addUsersInExitBlock (OrigLoop, RecipeBuilder, *Plan,
8786
+ Legal->getInductionVars ());
8787
8787
8788
8788
assert (isa<VPRegionBlock>(Plan->getVectorLoopRegion ()) &&
8789
8789
!Plan->getVectorLoopRegion ()->getEntryBasicBlock ()->empty () &&
0 commit comments