@@ -511,7 +511,8 @@ class InnerLoopVectorizer {
511
511
MinProfitableTripCount(MinProfitableTripCount), UF(UnrollFactor),
512
512
Builder(PSE.getSE()->getContext()), Cost(CM), BFI(BFI), PSI(PSI),
513
513
RTChecks(RTChecks), Plan(Plan),
514
- VectorPHVPB(Plan.getVectorLoopRegion()->getSinglePredecessor()) {}
514
+ VectorPHVPBB(cast<VPBasicBlock>(
515
+ Plan.getVectorLoopRegion()->getSinglePredecessor())) {}
515
516
516
517
virtual ~InnerLoopVectorizer () = default ;
517
518
@@ -645,7 +646,7 @@ class InnerLoopVectorizer {
645
646
646
647
// / The vector preheader block of \p Plan, used as target for check blocks
647
648
// / introduced during skeleton creation.
648
- VPBlockBase *VectorPHVPB ;
649
+ VPBasicBlock *VectorPHVPBB ;
649
650
};
650
651
651
652
// / Encapsulate information regarding vectorization of a loop and its epilogue.
@@ -2277,11 +2278,11 @@ void InnerLoopVectorizer::introduceCheckBlockInVPlan(BasicBlock *CheckIRBB) {
2277
2278
// Note: The block with the minimum trip-count check is already connected
2278
2279
// during earlier VPlan construction.
2279
2280
VPBlockBase *ScalarPH = Plan.getScalarPreheader ();
2280
- VPBlockBase *PreVectorPH = VectorPHVPB ->getSinglePredecessor ();
2281
+ VPBlockBase *PreVectorPH = VectorPHVPBB ->getSinglePredecessor ();
2281
2282
assert (PreVectorPH->getNumSuccessors () == 2 && " Expected 2 successors" );
2282
2283
assert (PreVectorPH->getSuccessors ()[0 ] == ScalarPH && " Unexpected successor" );
2283
2284
VPIRBasicBlock *CheckVPIRBB = Plan.createVPIRBasicBlock (CheckIRBB);
2284
- VPBlockUtils::insertOnEdge (PreVectorPH, VectorPHVPB , CheckVPIRBB);
2285
+ VPBlockUtils::insertOnEdge (PreVectorPH, VectorPHVPBB , CheckVPIRBB);
2285
2286
PreVectorPH = CheckVPIRBB;
2286
2287
VPBlockUtils::connectBlocks (PreVectorPH, ScalarPH);
2287
2288
PreVectorPH->swapSuccessors ();
@@ -2388,7 +2389,8 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
2388
2389
// / VPBB are moved to the end of the newly created VPIRBasicBlock. VPBB must
2389
2390
// / have a single predecessor, which is rewired to the new VPIRBasicBlock. All
2390
2391
// / successors of VPBB, if any, are rewired to the new VPIRBasicBlock.
2391
- static void replaceVPBBWithIRVPBB (VPBasicBlock *VPBB, BasicBlock *IRBB) {
2392
+ static VPIRBasicBlock *replaceVPBBWithIRVPBB (VPBasicBlock *VPBB,
2393
+ BasicBlock *IRBB) {
2392
2394
VPIRBasicBlock *IRVPBB = VPBB->getPlan ()->createVPIRBasicBlock (IRBB);
2393
2395
auto IP = IRVPBB->begin ();
2394
2396
for (auto &R : make_early_inc_range (VPBB->phis ()))
@@ -2400,6 +2402,7 @@ static void replaceVPBBWithIRVPBB(VPBasicBlock *VPBB, BasicBlock *IRBB) {
2400
2402
2401
2403
VPBlockUtils::reassociateBlocks (VPBB, IRVPBB);
2402
2404
// VPBB is now dead and will be cleaned up when the plan gets destroyed.
2405
+ return IRVPBB;
2403
2406
}
2404
2407
2405
2408
void InnerLoopVectorizer::createVectorLoopSkeleton (StringRef Prefix) {
@@ -2503,6 +2506,7 @@ BasicBlock *InnerLoopVectorizer::createVectorizedLoopSkeleton() {
2503
2506
emitIterationCountCheck (LoopScalarPreHeader);
2504
2507
2505
2508
replaceVPBBWithIRVPBB (Plan.getScalarPreheader (), LoopScalarPreHeader);
2509
+ replaceVPBBWithIRVPBB (VectorPHVPBB, LoopVectorPreHeader);
2506
2510
return LoopVectorPreHeader;
2507
2511
}
2508
2512
@@ -7363,9 +7367,6 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7363
7367
//
7364
7368
// ===------------------------------------------------===//
7365
7369
7366
- // 2. Copy and widen instructions from the old loop into the new loop.
7367
- replaceVPBBWithIRVPBB (VectorPH, State.CFG .PrevBB );
7368
-
7369
7370
// Move check blocks to their final position.
7370
7371
// TODO: Move as part of VPIRBB execute and update impacted tests.
7371
7372
if (BasicBlock *MemCheckBlock = ILV.RTChecks .getMemRuntimeChecks ().second )
@@ -7521,12 +7522,13 @@ EpilogueVectorizerMainLoop::emitIterationCountCheck(BasicBlock *Bypass,
7521
7522
LoopVectorPreHeader = SplitBlock (TCCheckBlock, TCCheckBlock->getTerminator (),
7522
7523
static_cast <DominatorTree *>(nullptr ), LI,
7523
7524
nullptr , " vector.ph" );
7524
-
7525
7525
if (ForEpilogue) {
7526
7526
// Save the trip count so we don't have to regenerate it in the
7527
7527
// vec.epilog.iter.check. This is safe to do because the trip count
7528
7528
// generated here dominates the vector epilog iter check.
7529
7529
EPI.TripCount = Count;
7530
+ } else {
7531
+ VectorPHVPBB = replaceVPBBWithIRVPBB (VectorPHVPBB, LoopVectorPreHeader);
7530
7532
}
7531
7533
7532
7534
BranchInst &BI =
@@ -7560,6 +7562,8 @@ EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton() {
7560
7562
BasicBlock *VecEpilogueIterationCountCheck =
7561
7563
SplitBlock (LoopVectorPreHeader, LoopVectorPreHeader->begin (), DT, LI,
7562
7564
nullptr , " vec.epilog.iter.check" , true );
7565
+ VectorPHVPBB = replaceVPBBWithIRVPBB (VectorPHVPBB, LoopVectorPreHeader);
7566
+
7563
7567
emitMinimumVectorEpilogueIterCountCheck (LoopScalarPreHeader,
7564
7568
VecEpilogueIterationCountCheck);
7565
7569
AdditionalBypassBlock = VecEpilogueIterationCountCheck;
0 commit comments