@@ -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;
@@ -9040,8 +9037,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
90409037 if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
90419038 continue ;
90429039
9043- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9044- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9040+ RecurKind Kind = PhiR->getRecurrenceKind ();
90459041 assert (
90469042 !RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
90479043 !RecurrenceDescriptor::isFindIVRecurrenceKind (Kind) &&
@@ -9147,6 +9143,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91479143 if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
91489144 CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
91499145
9146+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9147+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91509148 // Non-FP RdxDescs will have all fast math flags set, so clear them.
91519149 FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
91529150 ? RdxDesc.getFastMathFlags ()
@@ -9177,7 +9175,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91779175 if (!PhiR)
91789176 continue ;
91799177
9180- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9178+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9179+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91819180 Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
91829181 // If tail is folded by masking, introduce selects between the phi
91839182 // and the users outside the vector region of each reduction, at the
@@ -9820,14 +9819,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98209819 }));
98219820 ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
98229821 ->getIncomingValueForBlock (L->getLoopPreheader ());
9823- const RecurrenceDescriptor &RdxDesc =
9824- ReductionPhi->getRecurrenceDescriptor ();
9825- RecurKind RK = RdxDesc.getRecurrenceKind ();
9822+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
98269823 if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
98279824 Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9828- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9829- " start value from ComputeAnyOfResult must match" );
9830-
98319825 // VPReductionPHIRecipes for AnyOf reductions expect a boolean as
98329826 // start value; compare the final value from the main vector loop
98339827 // to the start value.
@@ -9836,9 +9830,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98369830 ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
98379831 } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (RK)) {
98389832 Value *StartV = getStartValueFromReductionResult (RdxResult);
9839- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9840- " start value from ComputeFinIVResult must match" );
9841-
98429833 ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
98439834 EPI.MainLoopIterationCountCheck );
98449835
0 commit comments