@@ -513,16 +513,16 @@ class InnerLoopVectorizer {
513
513
// / Fix the non-induction PHIs in \p Plan.
514
514
void fixNonInductionPHIs (VPTransformState &State);
515
515
516
- // / Create a ResumePHI VPInstruction for the induction variable \p OrigPhi to
517
- // / resume iteration count in the scalar epilogue from where the vectorized
518
- // / loop left off, and add it to the scalar preheader of VPlan. \p Step is the
516
+ // / Create a ResumePHI VPInstruction for the induction \p PhiRIR to resume
517
+ // / iteration count in the scalar epilogue from where the vectorized loop
518
+ // / left off, and add it to the scalar preheader of VPlan. \p Step is the
519
519
// / SCEV-expanded induction step to use. In cases where the loop skeleton is
520
520
// / more complicated (i.e., epilogue vectorization) and the resume values can
521
521
// / come from an additional bypass block, the \p AdditionalBypass pair
522
522
// / provides this additional bypass block along with the resume value coming
523
523
// / from it.
524
- void createInductionResumeValue (
525
- VPIRInstruction *PhiIRI, PHINode *OrigPhi, const InductionDescriptor &ID,
524
+ void createInductionResumeVPValue (
525
+ VPIRInstruction *PhiIRI, const InductionDescriptor &ID,
526
526
Value *Step, ArrayRef<BasicBlock *> BypassBlocks,
527
527
VPBuilder &ScalarPHBuilder,
528
528
std::pair<BasicBlock *, Value *> AdditionalBypass = {nullptr , nullptr });
@@ -579,7 +579,7 @@ class InnerLoopVectorizer {
579
579
// / vectorization) and the resume values can come from an additional bypass
580
580
// / block, the \p AdditionalBypass pair provides information about the bypass
581
581
// / block and the end value on the edge from bypass to this loop.
582
- void createInductionResumeValues (
582
+ void createInductionResumeVPValues (
583
583
const SCEV2ValueTy &ExpandedSCEVs,
584
584
std::pair<BasicBlock *, Value *> AdditionalBypass = {nullptr , nullptr });
585
585
@@ -2592,11 +2592,12 @@ void InnerLoopVectorizer::createVectorLoopSkeleton(StringRef Prefix) {
2592
2592
nullptr , Twine (Prefix) + " scalar.ph" );
2593
2593
}
2594
2594
2595
- void InnerLoopVectorizer::createInductionResumeValue (
2596
- VPIRInstruction *PhiR, PHINode *OrigPhi, const InductionDescriptor &II,
2595
+ void InnerLoopVectorizer::createInductionResumeVPValue (
2596
+ VPIRInstruction *PhiR, const InductionDescriptor &II,
2597
2597
Value *Step, ArrayRef<BasicBlock *> BypassBlocks,
2598
2598
VPBuilder &ScalarPHBuilder,
2599
2599
std::pair<BasicBlock *, Value *> AdditionalBypass) {
2600
+ auto *OrigPhi = cast<PHINode>(&PhiR->getInstruction ());
2600
2601
Value *VectorTripCount = getOrCreateVectorTripCount (LoopVectorPreHeader);
2601
2602
assert (VectorTripCount && " Expected valid arguments" );
2602
2603
@@ -2659,7 +2660,7 @@ static Value *getExpandedStep(const InductionDescriptor &ID,
2659
2660
return I->second ;
2660
2661
}
2661
2662
2662
- void InnerLoopVectorizer::createInductionResumeValues (
2663
+ void InnerLoopVectorizer::createInductionResumeVPValues (
2663
2664
const SCEV2ValueTy &ExpandedSCEVs,
2664
2665
std::pair<BasicBlock *, Value *> AdditionalBypass) {
2665
2666
assert (((AdditionalBypass.first && AdditionalBypass.second ) ||
@@ -2681,8 +2682,8 @@ void InnerLoopVectorizer::createInductionResumeValues(
2681
2682
if (!Legal->getInductionVars ().contains (Phi))
2682
2683
continue ;
2683
2684
const InductionDescriptor &II = Legal->getInductionVars ().find (Phi)->second ;
2684
- createInductionResumeValue (
2685
- PhiR, Phi, II, getExpandedStep (II, ExpandedSCEVs), LoopBypassBlocks,
2685
+ createInductionResumeVPValue (
2686
+ PhiR, II, getExpandedStep (II, ExpandedSCEVs), LoopBypassBlocks,
2686
2687
ScalarPHBuilder, AdditionalBypass);
2687
2688
}
2688
2689
}
@@ -2746,7 +2747,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
2746
2747
emitMemRuntimeChecks (LoopScalarPreHeader);
2747
2748
2748
2749
// Emit phis for the new starting index of the scalar loop.
2749
- createInductionResumeValues (ExpandedSCEVs);
2750
+ createInductionResumeVPValues (ExpandedSCEVs);
2750
2751
2751
2752
return {LoopVectorPreHeader, nullptr };
2752
2753
}
@@ -7862,34 +7863,7 @@ EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(
7862
7863
// Create induction resume values and ResumePhis for the inductions in the
7863
7864
// epilogue loop in the VPlan for the epilogue vector loop.
7864
7865
VPBasicBlock *ScalarPHVPBB = Plan.getScalarPreheader ();
7865
- VPBuilder ScalarPHBuilder (ScalarPHVPBB, ScalarPHVPBB->begin ());
7866
- for (VPRecipeBase &R :
7867
- Plan.getVectorLoopRegion ()->getEntryBasicBlock ()->phis ()) {
7868
- // Create induction resume values for both widened pointer and
7869
- // integer/fp inductions and update the start value of the induction
7870
- // recipes to use the resume value.
7871
- PHINode *IndPhi = nullptr ;
7872
- const InductionDescriptor *ID;
7873
- if (auto *Ind = dyn_cast<VPWidenPointerInductionRecipe>(&R)) {
7874
- IndPhi = cast<PHINode>(Ind->getUnderlyingValue ());
7875
- ID = &Ind->getInductionDescriptor ();
7876
- } else if (auto *WidenInd = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R)) {
7877
- IndPhi = WidenInd->getPHINode ();
7878
- ID = &WidenInd->getInductionDescriptor ();
7879
- } else {
7880
- continue ;
7881
- }
7882
-
7883
- auto *ScalarLoopHeader = Plan.getScalarHeader ();
7884
- for (VPRecipeBase &R : *ScalarLoopHeader) {
7885
- auto *PhiR = cast<VPIRInstruction>(&R);
7886
- if (&PhiR->getInstruction () != IndPhi)
7887
- continue ;
7888
- createInductionResumeValue (PhiR, IndPhi, *ID,
7889
- getExpandedStep (*ID, ExpandedSCEVs),
7890
- LoopBypassBlocks, ScalarPHBuilder);
7891
- }
7892
- }
7866
+ createInductionResumeVPValues (ExpandedSCEVs, LoopBypassBlocks);
7893
7867
7894
7868
return {LoopVectorPreHeader, nullptr };
7895
7869
}
@@ -8070,7 +8044,7 @@ EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(
8070
8044
// check, then the resume value for the induction variable comes from
8071
8045
// the trip count of the main vector loop, hence passing the AdditionalBypass
8072
8046
// argument.
8073
- createInductionResumeValues (ExpandedSCEVs,
8047
+ createInductionResumeVPValues (ExpandedSCEVs,
8074
8048
{VecEpilogueIterationCountCheck,
8075
8049
EPI.VectorTripCount } /* AdditionalBypass */ );
8076
8050
0 commit comments