@@ -7706,8 +7706,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7706
7706
BestVPlan.execute(&State);
7707
7707
7708
7708
// 2.5 Collect reduction resume values.
7709
- auto *ExitVPBB =
7710
- cast<VPBasicBlock>(BestVPlan.getVectorLoopRegion()->getSingleSuccessor());
7709
+ auto *ExitVPBB = BestVPlan.getMiddleBlock();
7711
7710
if (VectorizingEpilogue)
7712
7711
for (VPRecipeBase &R : *ExitVPBB) {
7713
7712
fixReductionScalarResumeWhenVectorizingEpilog(
@@ -8798,8 +8797,7 @@ static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, bool HasNUW,
8798
8797
static SetVector<VPIRInstruction *> collectUsersInExitBlock(
8799
8798
Loop *OrigLoop, VPRecipeBuilder &Builder, VPlan &Plan,
8800
8799
const MapVector<PHINode *, InductionDescriptor> &Inductions) {
8801
- auto *MiddleVPBB =
8802
- cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSingleSuccessor());
8800
+ auto *MiddleVPBB = Plan.getMiddleBlock();
8803
8801
// No edge from the middle block to the unique exit block has been inserted
8804
8802
// and there is nothing to fix from vector loop; phis should have incoming
8805
8803
// from scalar loop only.
@@ -8845,8 +8843,7 @@ addUsersInExitBlock(VPlan &Plan,
8845
8843
if (ExitUsersToFix.empty())
8846
8844
return;
8847
8845
8848
- auto *MiddleVPBB =
8849
- cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSingleSuccessor());
8846
+ auto *MiddleVPBB = Plan.getMiddleBlock();
8850
8847
VPBuilder B(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
8851
8848
8852
8849
// Introduce extract for exiting values and update the VPIRInstructions
@@ -8883,7 +8880,7 @@ static void addLiveOutsForFirstOrderRecurrences(
8883
8880
// TODO: Should be replaced by
8884
8881
// Plan->getScalarLoopRegion()->getSinglePredecessor() in the future once the
8885
8882
// scalar region is modeled as well.
8886
- auto *MiddleVPBB = cast<VPBasicBlock>(VectorRegion->getSingleSuccessor() );
8883
+ auto *MiddleVPBB = Plan.getMiddleBlock( );
8887
8884
VPBasicBlock *ScalarPHVPBB = nullptr;
8888
8885
if (MiddleVPBB->getNumSuccessors() == 2) {
8889
8886
// Order is strict: first is the exit block, second is the scalar preheader.
@@ -9085,8 +9082,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9085
9082
bool NeedsBlends = BB != HeaderBB && !BB->phis().empty();
9086
9083
return Legal->blockNeedsPredication(BB) || NeedsBlends;
9087
9084
});
9088
- auto *MiddleVPBB =
9089
- cast<VPBasicBlock>(Plan->getVectorLoopRegion()->getSingleSuccessor());
9085
+ auto *MiddleVPBB = Plan->getMiddleBlock();
9090
9086
VPBasicBlock::iterator MBIP = MiddleVPBB->getFirstNonPhi();
9091
9087
for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO())) {
9092
9088
// Relevant instructions from basic block BB will be grouped into VPRecipe
@@ -9305,8 +9301,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9305
9301
using namespace VPlanPatternMatch;
9306
9302
VPRegionBlock *VectorLoopRegion = Plan->getVectorLoopRegion();
9307
9303
VPBasicBlock *Header = VectorLoopRegion->getEntryBasicBlock();
9308
- VPBasicBlock *MiddleVPBB =
9309
- cast<VPBasicBlock>(VectorLoopRegion->getSingleSuccessor());
9304
+ VPBasicBlock *MiddleVPBB = Plan->getMiddleBlock();
9310
9305
for (VPRecipeBase &R : Header->phis()) {
9311
9306
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
9312
9307
if (!PhiR || !PhiR->isInLoop() || (MinVF.isScalar() && !PhiR->isOrdered()))
0 commit comments