@@ -479,7 +479,8 @@ class InnerLoopVectorizer {
479
479
AC (AC), ORE(ORE), VF(VecWidth),
480
480
MinProfitableTripCount(MinProfitableTripCount), UF(UnrollFactor),
481
481
Builder(PSE.getSE()->getContext()), Legal(LVL), Cost(CM), BFI(BFI),
482
- PSI(PSI), RTChecks(RTChecks), Plan(Plan) {
482
+ PSI(PSI), RTChecks(RTChecks), Plan(Plan),
483
+ VectorPHVPB(Plan.getEntry()->getSingleSuccessor()) {
483
484
// Query this against the original loop and save it here because the profile
484
485
// of the original loop header may change as the transformation happens.
485
486
OptForSizeBasedOnProfile = llvm::shouldOptimizeForSize (
@@ -582,6 +583,11 @@ class InnerLoopVectorizer {
582
583
virtual void printDebugTracesAtStart () {}
583
584
virtual void printDebugTracesAtEnd () {}
584
585
586
+ // / Introduces a new VPIRBasicBlock for \p CheckIRBB to Plan between the
587
+ // / vector preheader and its predecessor, also connecting the new block to the
588
+ // / scalar preheader.
589
+ void introduceCheckBlockInVPlan (BasicBlock *CheckIRBB);
590
+
585
591
// / The original loop.
586
592
Loop *OrigLoop;
587
593
@@ -676,6 +682,10 @@ class InnerLoopVectorizer {
676
682
BasicBlock *AdditionalBypassBlock = nullptr ;
677
683
678
684
VPlan &Plan;
685
+
686
+ // / The vector preheader block of \p Plan, used as target for check blocks
687
+ // / introduced during skeleton creation.
688
+ VPBlockBase *VectorPHVPB;
679
689
};
680
690
681
691
// / Encapsulate information regarding vectorization of a loop and its epilogue.
@@ -2443,19 +2453,15 @@ InnerLoopVectorizer::getOrCreateVectorTripCount(BasicBlock *InsertBlock) {
2443
2453
return VectorTripCount;
2444
2454
}
2445
2455
2446
- // / Introduces a new VPIRBasicBlock for \p CheckIRBB to \p Plan between the
2447
- // / vector preheader and its predecessor, also connecting the new block to the
2448
- // / scalar preheader.
2449
- static void introduceCheckBlockInVPlan (VPlan &Plan, BasicBlock *CheckIRBB) {
2456
+ void InnerLoopVectorizer::introduceCheckBlockInVPlan (BasicBlock *CheckIRBB) {
2450
2457
VPBlockBase *ScalarPH = Plan.getScalarPreheader ();
2451
- VPBlockBase *VectorPH = Plan.getVectorPreheader ();
2452
- VPBlockBase *PreVectorPH = VectorPH->getSinglePredecessor ();
2458
+ VPBlockBase *PreVectorPH = VectorPHVPB->getSinglePredecessor ();
2453
2459
if (PreVectorPH->getNumSuccessors () != 1 ) {
2454
2460
assert (PreVectorPH->getNumSuccessors () == 2 && " Expected 2 successors" );
2455
2461
assert (PreVectorPH->getSuccessors ()[0 ] == ScalarPH &&
2456
2462
" Unexpected successor" );
2457
2463
VPIRBasicBlock *CheckVPIRBB = Plan.createVPIRBasicBlock (CheckIRBB);
2458
- VPBlockUtils::insertOnEdge (PreVectorPH, VectorPH , CheckVPIRBB);
2464
+ VPBlockUtils::insertOnEdge (PreVectorPH, VectorPHVPB , CheckVPIRBB);
2459
2465
PreVectorPH = CheckVPIRBB;
2460
2466
}
2461
2467
VPBlockUtils::connectBlocks (PreVectorPH, ScalarPH);
@@ -2544,7 +2550,7 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
2544
2550
LoopBypassBlocks.push_back (TCCheckBlock);
2545
2551
2546
2552
// TODO: Wrap LoopVectorPreHeader in VPIRBasicBlock here.
2547
- introduceCheckBlockInVPlan (Plan, TCCheckBlock);
2553
+ introduceCheckBlockInVPlan (TCCheckBlock);
2548
2554
}
2549
2555
2550
2556
BasicBlock *InnerLoopVectorizer::emitSCEVChecks (BasicBlock *Bypass) {
@@ -2562,7 +2568,7 @@ BasicBlock *InnerLoopVectorizer::emitSCEVChecks(BasicBlock *Bypass) {
2562
2568
LoopBypassBlocks.push_back (SCEVCheckBlock);
2563
2569
AddedSafetyChecks = true ;
2564
2570
2565
- introduceCheckBlockInVPlan (Plan, SCEVCheckBlock);
2571
+ introduceCheckBlockInVPlan (SCEVCheckBlock);
2566
2572
return SCEVCheckBlock;
2567
2573
}
2568
2574
@@ -2599,7 +2605,7 @@ BasicBlock *InnerLoopVectorizer::emitMemRuntimeChecks(BasicBlock *Bypass) {
2599
2605
2600
2606
AddedSafetyChecks = true ;
2601
2607
2602
- introduceCheckBlockInVPlan (Plan, MemCheckBlock);
2608
+ introduceCheckBlockInVPlan (MemCheckBlock);
2603
2609
return MemCheckBlock;
2604
2610
}
2605
2611
@@ -7952,7 +7958,7 @@ EpilogueVectorizerMainLoop::emitIterationCountCheck(BasicBlock *Bypass,
7952
7958
setBranchWeights (BI, MinItersBypassWeights, /* IsExpected=*/ false );
7953
7959
ReplaceInstWithInst (TCCheckBlock->getTerminator (), &BI);
7954
7960
7955
- introduceCheckBlockInVPlan (Plan, TCCheckBlock);
7961
+ introduceCheckBlockInVPlan (TCCheckBlock);
7956
7962
return TCCheckBlock;
7957
7963
}
7958
7964
@@ -8092,7 +8098,7 @@ EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(
8092
8098
Plan.setEntry (NewEntry);
8093
8099
// OldEntry is now dead and will be cleaned up when the plan gets destroyed.
8094
8100
8095
- introduceCheckBlockInVPlan (Plan, Insert);
8101
+ introduceCheckBlockInVPlan (Insert);
8096
8102
return Insert;
8097
8103
}
8098
8104
0 commit comments