@@ -7267,8 +7267,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72677267
72687268 auto *EpiRedHeaderPhi =
72697269 cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7270- const RecurrenceDescriptor &RdxDesc =
7271- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7270+ RecurKind Kind = EpiRedHeaderPhi->getRecurrenceKind ();
72727271 Value *MainResumeValue;
72737272 if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
72747273 assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7277,8 +7276,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72777276 MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
72787277 } else
72797278 MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7280- if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
7281- RdxDesc.getRecurrenceKind ())) {
7279+ if (RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind)) {
72827280 [[maybe_unused]] Value *StartV =
72837281 EpiRedResult->getOperand (1 )->getLiveInIRValue ();
72847282 auto *Cmp = cast<ICmpInst>(MainResumeValue);
@@ -7288,8 +7286,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72887286 " AnyOf expected to start by comparing main resume value to original "
72897287 " start value" );
72907288 MainResumeValue = Cmp->getOperand (0 );
7291- } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (
7292- RdxDesc.getRecurrenceKind ())) {
7289+ } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (Kind)) {
72937290 Value *StartV = getStartValueFromReductionResult (EpiRedResult);
72947291 Value *SentinelV = EpiRedResult->getOperand (2 )->getLiveInIRValue ();
72957292 using namespace llvm ::PatternMatch;
@@ -9070,8 +9067,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
90709067 if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
90719068 continue ;
90729069
9073- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9074- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9070+ RecurKind Kind = PhiR->getRecurrenceKind ();
90759071 assert (
90769072 !RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
90779073 !RecurrenceDescriptor::isFindIVRecurrenceKind (Kind) &&
@@ -9177,6 +9173,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91779173 if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
91789174 CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
91799175
9176+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9177+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91809178 // Non-FP RdxDescs will have all fast math flags set, so clear them.
91819179 FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
91829180 ? RdxDesc.getFastMathFlags ()
@@ -9207,7 +9205,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92079205 if (!PhiR)
92089206 continue ;
92099207
9210- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9208+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9209+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
92119210 Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
92129211 // If tail is folded by masking, introduce selects between the phi
92139212 // and the users outside the vector region of each reduction, at the
@@ -9853,14 +9852,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98539852 }));
98549853 ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
98559854 ->getIncomingValueForBlock (L->getLoopPreheader ());
9856- const RecurrenceDescriptor &RdxDesc =
9857- ReductionPhi->getRecurrenceDescriptor ();
9858- RecurKind RK = RdxDesc.getRecurrenceKind ();
9855+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
98599856 if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
98609857 Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9861- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9862- " start value from ComputeAnyOfResult must match" );
9863-
98649858 // VPReductionPHIRecipes for AnyOf reductions expect a boolean as
98659859 // start value; compare the final value from the main vector loop
98669860 // to the start value.
@@ -9869,9 +9863,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98699863 ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
98709864 } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (RK)) {
98719865 Value *StartV = getStartValueFromReductionResult (RdxResult);
9872- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9873- " start value from ComputeFinIVResult must match" );
9874-
98759866 ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
98769867 EPI.MainLoopIterationCountCheck );
98779868
0 commit comments