@@ -7692,8 +7692,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7692
7692
BestVPlan.execute (&State);
7693
7693
7694
7694
// 2.5 Collect reduction resume values.
7695
- auto *ExitVPBB =
7696
- cast<VPBasicBlock>(BestVPlan.getVectorLoopRegion ()->getSingleSuccessor ());
7695
+ auto *ExitVPBB = BestVPlan.getMiddleBlock ();
7697
7696
for (VPRecipeBase &R : *ExitVPBB) {
7698
7697
createAndCollectMergePhiForReduction (
7699
7698
dyn_cast<VPInstruction>(&R), State, OrigLoop,
@@ -8778,8 +8777,7 @@ static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, bool HasNUW,
8778
8777
static SetVector<VPIRInstruction *> collectUsersInExitBlock (
8779
8778
Loop *OrigLoop, VPRecipeBuilder &Builder, VPlan &Plan,
8780
8779
const MapVector<PHINode *, InductionDescriptor> &Inductions) {
8781
- auto *MiddleVPBB =
8782
- cast<VPBasicBlock>(Plan.getVectorLoopRegion ()->getSingleSuccessor ());
8780
+ auto *MiddleVPBB = Plan.getMiddleBlock ();
8783
8781
// No edge from the middle block to the unique exit block has been inserted
8784
8782
// and there is nothing to fix from vector loop; phis should have incoming
8785
8783
// from scalar loop only.
@@ -8825,8 +8823,7 @@ addUsersInExitBlock(VPlan &Plan,
8825
8823
if (ExitUsersToFix.empty ())
8826
8824
return ;
8827
8825
8828
- auto *MiddleVPBB =
8829
- cast<VPBasicBlock>(Plan.getVectorLoopRegion ()->getSingleSuccessor ());
8826
+ auto *MiddleVPBB = Plan.getMiddleBlock ();
8830
8827
VPBuilder B (MiddleVPBB, MiddleVPBB->getFirstNonPhi ());
8831
8828
8832
8829
// Introduce extract for exiting values and update the VPIRInstructions
@@ -8863,7 +8860,7 @@ static void addLiveOutsForFirstOrderRecurrences(
8863
8860
// TODO: Should be replaced by
8864
8861
// Plan->getScalarLoopRegion()->getSinglePredecessor() in the future once the
8865
8862
// scalar region is modeled as well.
8866
- auto *MiddleVPBB = cast<VPBasicBlock>(VectorRegion-> getSingleSuccessor () );
8863
+ auto *MiddleVPBB = Plan. getMiddleBlock ( );
8867
8864
VPBasicBlock *ScalarPHVPBB = nullptr ;
8868
8865
if (MiddleVPBB->getNumSuccessors () == 2 ) {
8869
8866
// Order is strict: first is the exit block, second is the scalar preheader.
@@ -9065,8 +9062,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9065
9062
bool NeedsBlends = BB != HeaderBB && !BB->phis ().empty ();
9066
9063
return Legal->blockNeedsPredication (BB) || NeedsBlends;
9067
9064
});
9068
- auto *MiddleVPBB =
9069
- cast<VPBasicBlock>(Plan->getVectorLoopRegion ()->getSingleSuccessor ());
9065
+ auto *MiddleVPBB = Plan->getMiddleBlock ();
9070
9066
VPBasicBlock::iterator MBIP = MiddleVPBB->getFirstNonPhi ();
9071
9067
for (BasicBlock *BB : make_range (DFS.beginRPO (), DFS.endRPO ())) {
9072
9068
// Relevant instructions from basic block BB will be grouped into VPRecipe
@@ -9277,8 +9273,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9277
9273
using namespace VPlanPatternMatch ;
9278
9274
VPRegionBlock *VectorLoopRegion = Plan->getVectorLoopRegion ();
9279
9275
VPBasicBlock *Header = VectorLoopRegion->getEntryBasicBlock ();
9280
- VPBasicBlock *MiddleVPBB =
9281
- cast<VPBasicBlock>(VectorLoopRegion->getSingleSuccessor ());
9276
+ VPBasicBlock *MiddleVPBB = Plan->getMiddleBlock ();
9282
9277
for (VPRecipeBase &R : Header->phis ()) {
9283
9278
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
9284
9279
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
0 commit comments