@@ -5176,7 +5176,7 @@ LoopVectorizationCostModel::selectInterleaveCount(VPlan &Plan, ElementCount VF,
51765176 const RecurrenceDescriptor &RdxDesc = Reduction.second ;
51775177 RecurKind RK = RdxDesc.getRecurrenceKind ();
51785178 return RecurrenceDescriptor::isAnyOfRecurrenceKind (RK) ||
5179- RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK);
5179+ RecurrenceDescriptor::isFindIVRecurrenceKind (RK);
51805180 });
51815181 if (HasSelectCmpReductions) {
51825182 LLVM_DEBUG (dbgs () << " LV: Not interleaving select-cmp reductions.\n " );
@@ -7549,7 +7549,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
75497549 auto *EpiRedResult = dyn_cast<VPInstruction>(R);
75507550 if (!EpiRedResult ||
75517551 (EpiRedResult->getOpcode () != VPInstruction::ComputeReductionResult &&
7552- EpiRedResult->getOpcode () != VPInstruction::ComputeFindLastIVResult ))
7552+ EpiRedResult->getOpcode () != VPInstruction::ComputeFindIVResult ))
75537553 return ;
75547554
75557555 auto *EpiRedHeaderPhi =
@@ -7567,7 +7567,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
75677567 " AnyOf expected to start by comparing main resume value to original "
75687568 " start value" );
75697569 MainResumeValue = Cmp->getOperand (0 );
7570- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7570+ } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (
75717571 RdxDesc.getRecurrenceKind ())) {
75727572 using namespace llvm ::PatternMatch;
75737573 Value *Cmp, *OrigResumeV, *CmpOp;
@@ -9360,7 +9360,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
93609360 RecurKind Kind = RdxDesc.getRecurrenceKind ();
93619361 assert (
93629362 !RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9363- !RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
9363+ !RecurrenceDescriptor::isFindIVRecurrenceKind (Kind) &&
93649364 " AnyOf and FindLast reductions are not allowed for in-loop reductions" );
93659365
93669366 // Collect the chain of "link" recipes for the reduction starting at PhiR.
@@ -9517,7 +9517,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
95179517 (cast<VPInstruction>(&U)->getOpcode () ==
95189518 VPInstruction::ComputeReductionResult ||
95199519 cast<VPInstruction>(&U)->getOpcode () ==
9520- VPInstruction::ComputeFindLastIVResult );
9520+ VPInstruction::ComputeFindIVResult );
95219521 });
95229522 if (CM.usePredicatedReductionSelect ())
95239523 PhiR->setOperand (1 , NewExitingVPV);
@@ -9562,11 +9562,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
95629562 VPInstruction *FinalReductionResult;
95639563 VPBuilder::InsertPointGuard Guard (Builder);
95649564 Builder.setInsertPoint (MiddleVPBB, IP);
9565- if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
9565+ if (RecurrenceDescriptor::isFindIVRecurrenceKind (
95669566 RdxDesc.getRecurrenceKind ())) {
95679567 VPValue *Start = PhiR->getStartValue ();
95689568 FinalReductionResult =
9569- Builder.createNaryOp (VPInstruction::ComputeFindLastIVResult ,
9569+ Builder.createNaryOp (VPInstruction::ComputeFindIVResult ,
95709570 {PhiR, Start, NewExitingVPV}, ExitDL);
95719571 } else {
95729572 FinalReductionResult = Builder.createNaryOp (
@@ -9613,11 +9613,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
96139613 continue ;
96149614 }
96159615
9616- if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
9616+ if (RecurrenceDescriptor::isFindIVRecurrenceKind (
96179617 RdxDesc.getRecurrenceKind ())) {
9618- // Adjust the start value for FindLastIV recurrences to use the sentinel
9619- // value after generating the ResumePhi recipe, which uses the original
9620- // start value.
9618+ // Adjust the start value for FindFirstIV/ FindLastIV recurrences to use
9619+ // the sentinel value after generating the ResumePhi recipe, which uses
9620+ // the original start value.
96219621 PhiR->setOperand (0 , Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ()));
96229622 }
96239623 }
@@ -9985,18 +9985,18 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
99859985 VPlanTransforms::runPass (VPlanTransforms::removeDeadRecipes, MainPlan);
99869986
99879987 using namespace VPlanPatternMatch ;
9988- // When vectorizing the epilogue, FindLastIV reductions can introduce multiple
9989- // uses of undef/poison. If the reduction start value may be undef or poison
9990- // it needs to be frozen and the frozen start has to be used when computing
9991- // the reduction result. We also need to use the frozen value in the resume
9992- // phi generated by the main vector loop, as this is also used to compute the
9993- // reduction result after the epilogue vector loop.
9988+ // When vectorizing the epilogue, FindFirstIV & FindLastIV reductions can
9989+ // introduce multiple uses of undef/poison. If the reduction start value may
9990+ // be undef or poison it needs to be frozen and the frozen start has to be
9991+ // used when computing the reduction result. We also need to use the frozen
9992+ // value in the resume phi generated by the main vector loop, as this is also
9993+ // used to compute the reduction result after the epilogue vector loop.
99949994 auto AddFreezeForFindLastIVReductions = [](VPlan &Plan,
99959995 bool UpdateResumePhis) {
99969996 VPBuilder Builder (Plan.getEntry ());
99979997 for (VPRecipeBase &R : *Plan.getMiddleBlock ()) {
99989998 auto *VPI = dyn_cast<VPInstruction>(&R);
9999- if (!VPI || VPI->getOpcode () != VPInstruction::ComputeFindLastIVResult )
9999+ if (!VPI || VPI->getOpcode () != VPInstruction::ComputeFindIVResult )
1000010000 continue ;
1000110001 VPValue *OrigStart = VPI->getOperand (1 );
1000210002 if (isGuaranteedNotToBeUndefOrPoison (OrigStart->getLiveInIRValue ()))
@@ -10107,17 +10107,17 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
1010710107 IRBuilder<> Builder (PBB, PBB->getFirstNonPHIIt ());
1010810108 ResumeV =
1010910109 Builder.CreateICmpNE (ResumeV, RdxDesc.getRecurrenceStartValue ());
10110- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
10110+ } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (RK)) {
1011110111 ToFrozen[RdxDesc.getRecurrenceStartValue ()] =
1011210112 cast<PHINode>(ResumeV)->getIncomingValueForBlock (
1011310113 EPI.MainLoopIterationCountCheck );
1011410114
10115- // VPReductionPHIRecipe for FindLastIV reductions requires an adjustment
10116- // to the resume value. The resume value is adjusted to the sentinel
10117- // value when the final value from the main vector loop equals the start
10118- // value. This ensures correctness when the start value might not be
10119- // less than the minimum value of a monotonically increasing induction
10120- // variable.
10115+ // VPReductionPHIRecipe for FindFirstIV/ FindLastIV reductions requires
10116+ // an adjustment to the resume value. The resume value is adjusted to
10117+ // the sentinel value when the final value from the main vector loop
10118+ // equals the start value. This ensures correctness when the start value
10119+ // might not be less than the minimum value of a monotonically
10120+ // increasing induction variable.
1012110121 BasicBlock *ResumeBB = cast<Instruction>(ResumeV)->getParent ();
1012210122 IRBuilder<> Builder (ResumeBB, ResumeBB->getFirstNonPHIIt ());
1012310123 Value *Cmp = Builder.CreateICmpEQ (
0 commit comments