@@ -2354,12 +2354,15 @@ EpilogueVectorizerMainLoop::createIterationCountCheck(ElementCount VF,
23542354}
23552355
23562356// / Replace \p VPBB with a VPIRBasicBlock wrapping \p IRBB. All recipes from \p
2357- // / VPBB are moved to the end of the newly created VPIRBasicBlock. VPBB must
2358- // / have a single predecessor, which is rewired to the new VPIRBasicBlock. All
2359- // / successors of VPBB, if any, are rewired to the new VPIRBasicBlock.
2360- static VPIRBasicBlock *replaceVPBBWithIRVPBB (VPlan &Plan, VPBasicBlock *VPBB,
2361- BasicBlock *IRBB) {
2362- VPIRBasicBlock *IRVPBB = Plan.createVPIRBasicBlock (IRBB);
2357+ // / VPBB are moved to the end of the newly created VPIRBasicBlock. All
2358+ // / predecessors and successors of VPBB, if any, are rewired to the new
2359+ // / VPIRBasicBlock. If \p VPBB may be unreachable, \p Plan must be passed.
2360+ static VPIRBasicBlock *replaceVPBBWithIRVPBB (VPBasicBlock *VPBB,
2361+ BasicBlock *IRBB,
2362+ VPlan *Plan = nullptr ) {
2363+ if (!Plan)
2364+ Plan = VPBB->getPlan ();
2365+ VPIRBasicBlock *IRVPBB = Plan->createVPIRBasicBlock (IRBB);
23632366 auto IP = IRVPBB->begin ();
23642367 for (auto &R : make_early_inc_range (VPBB->phis ()))
23652368 R.moveBefore (*IRVPBB, IP);
@@ -2570,7 +2573,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
25702573 // Remove redundant induction instructions.
25712574 cse (HeaderBB);
25722575
2573- if (Plan.getScalarPreheader ()->getNumPredecessors () == 0 )
2576+ if (Plan.getScalarPreheader ()->hasPredecessors () )
25742577 return ;
25752578
25762579 // Set/update profile weights for the vector and remainder loops as original
@@ -7274,8 +7277,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
72747277 BasicBlock *EntryBB =
72757278 cast<VPIRBasicBlock>(BestVPlan.getEntry ())->getIRBasicBlock ();
72767279 State.CFG .PrevBB = ILV.createVectorizedLoopSkeleton ();
7277- replaceVPBBWithIRVPBB (BestVPlan, BestVPlan .getScalarPreheader (),
7278- State.CFG .PrevBB ->getSingleSuccessor ());
7280+ replaceVPBBWithIRVPBB (BestVPlan.getScalarPreheader (),
7281+ State.CFG .PrevBB ->getSingleSuccessor (), &BestVPlan );
72797282 VPlanTransforms::removeDeadRecipes (BestVPlan);
72807283
72817284 assert (verifyVPlanIsValid (BestVPlan, true /* VerifyLate*/ ) &&
@@ -7475,8 +7478,7 @@ EpilogueVectorizerMainLoop::emitIterationCountCheck(BasicBlock *Bypass,
74757478 // generated here dominates the vector epilog iter check.
74767479 EPI.TripCount = Count;
74777480 } else {
7478- VectorPHVPBB =
7479- replaceVPBBWithIRVPBB (Plan, VectorPHVPBB, LoopVectorPreHeader);
7481+ VectorPHVPBB = replaceVPBBWithIRVPBB (VectorPHVPBB, LoopVectorPreHeader);
74807482 }
74817483
74827484 BranchInst &BI =
@@ -7509,7 +7511,7 @@ BasicBlock *EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton() {
75097511 BasicBlock *VecEpilogueIterationCountCheck =
75107512 SplitBlock (LoopVectorPreHeader, LoopVectorPreHeader->begin (), DT, LI,
75117513 nullptr , " vec.epilog.iter.check" , true );
7512- VectorPHVPBB = replaceVPBBWithIRVPBB (Plan, VectorPHVPBB, LoopVectorPreHeader);
7514+ VectorPHVPBB = replaceVPBBWithIRVPBB (VectorPHVPBB, LoopVectorPreHeader);
75137515
75147516 emitMinimumVectorEpilogueIterCountCheck (ScalarPH,
75157517 VecEpilogueIterationCountCheck);
0 commit comments