@@ -513,16 +513,16 @@ class InnerLoopVectorizer {
513513 // / Fix the non-induction PHIs in \p Plan.
514514 void fixNonInductionPHIs (VPTransformState &State);
515515
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
519519 // / SCEV-expanded induction step to use. In cases where the loop skeleton is
520520 // / more complicated (i.e., epilogue vectorization) and the resume values can
521521 // / come from an additional bypass block, the \p AdditionalBypass pair
522522 // / provides this additional bypass block along with the resume value coming
523523 // / from it.
524- void createInductionResumeValue (
525- VPIRInstruction *PhiIRI, PHINode *OrigPhi, const InductionDescriptor &ID,
524+ void createInductionResumeVPValue (
525+ VPIRInstruction *PhiIRI, const InductionDescriptor &ID,
526526 Value *Step, ArrayRef<BasicBlock *> BypassBlocks,
527527 VPBuilder &ScalarPHBuilder,
528528 std::pair<BasicBlock *, Value *> AdditionalBypass = {nullptr , nullptr });
@@ -579,7 +579,7 @@ class InnerLoopVectorizer {
579579 // / vectorization) and the resume values can come from an additional bypass
580580 // / block, the \p AdditionalBypass pair provides information about the bypass
581581 // / block and the end value on the edge from bypass to this loop.
582- void createInductionResumeValues (
582+ void createInductionResumeVPValues (
583583 const SCEV2ValueTy &ExpandedSCEVs,
584584 std::pair<BasicBlock *, Value *> AdditionalBypass = {nullptr , nullptr });
585585
@@ -2592,11 +2592,12 @@ void InnerLoopVectorizer::createVectorLoopSkeleton(StringRef Prefix) {
25922592 nullptr , Twine (Prefix) + " scalar.ph" );
25932593}
25942594
2595- void InnerLoopVectorizer::createInductionResumeValue (
2596- VPIRInstruction *PhiR, PHINode *OrigPhi, const InductionDescriptor &II,
2595+ void InnerLoopVectorizer::createInductionResumeVPValue (
2596+ VPIRInstruction *PhiR, const InductionDescriptor &II,
25972597 Value *Step, ArrayRef<BasicBlock *> BypassBlocks,
25982598 VPBuilder &ScalarPHBuilder,
25992599 std::pair<BasicBlock *, Value *> AdditionalBypass) {
2600+ auto *OrigPhi = cast<PHINode>(&PhiR->getInstruction ());
26002601 Value *VectorTripCount = getOrCreateVectorTripCount (LoopVectorPreHeader);
26012602 assert (VectorTripCount && " Expected valid arguments" );
26022603
@@ -2659,7 +2660,7 @@ static Value *getExpandedStep(const InductionDescriptor &ID,
26592660 return I->second ;
26602661}
26612662
2662- void InnerLoopVectorizer::createInductionResumeValues (
2663+ void InnerLoopVectorizer::createInductionResumeVPValues (
26632664 const SCEV2ValueTy &ExpandedSCEVs,
26642665 std::pair<BasicBlock *, Value *> AdditionalBypass) {
26652666 assert (((AdditionalBypass.first && AdditionalBypass.second ) ||
@@ -2681,8 +2682,8 @@ void InnerLoopVectorizer::createInductionResumeValues(
26812682 if (!Legal->getInductionVars ().contains (Phi))
26822683 continue ;
26832684 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,
26862687 ScalarPHBuilder, AdditionalBypass);
26872688 }
26882689}
@@ -2746,7 +2747,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
27462747 emitMemRuntimeChecks (LoopScalarPreHeader);
27472748
27482749 // Emit phis for the new starting index of the scalar loop.
2749- createInductionResumeValues (ExpandedSCEVs);
2750+ createInductionResumeVPValues (ExpandedSCEVs);
27502751
27512752 return {LoopVectorPreHeader, nullptr };
27522753}
@@ -7862,34 +7863,7 @@ EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(
78627863 // Create induction resume values and ResumePhis for the inductions in the
78637864 // epilogue loop in the VPlan for the epilogue vector loop.
78647865 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);
78937867
78947868 return {LoopVectorPreHeader, nullptr };
78957869}
@@ -8070,7 +8044,7 @@ EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(
80708044 // check, then the resume value for the induction variable comes from
80718045 // the trip count of the main vector loop, hence passing the AdditionalBypass
80728046 // argument.
8073- createInductionResumeValues (ExpandedSCEVs,
8047+ createInductionResumeVPValues (ExpandedSCEVs,
80748048 {VecEpilogueIterationCountCheck,
80758049 EPI.VectorTripCount } /* AdditionalBypass */ );
80768050
0 commit comments