@@ -7271,8 +7271,6 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72717271
72727272 auto *EpiRedHeaderPhi =
72737273 cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7274- const RecurrenceDescriptor &RdxDesc =
7275- EpiRedHeaderPhi->getRecurrenceDescriptor ();
72767274 Value *MainResumeValue;
72777275 if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
72787276 assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7281,19 +7279,19 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72817279 MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
72827280 } else
72837281 MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7284- if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (
7285- RdxDesc. getRecurrenceKind () )) {
7282+ RecurKind Kind = EpiRedHeaderPhi-> getRecurrenceKind ();
7283+ if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind )) {
72867284 Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
72877285 (void )StartV;
7286+
72887287 auto *Cmp = cast<ICmpInst>(MainResumeValue);
72897288 assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
72907289 " AnyOf expected to start with ICMP_NE" );
72917290 assert (Cmp->getOperand (1 ) == StartV &&
72927291 " AnyOf expected to start by comparing main resume value to original "
72937292 " start value" );
72947293 MainResumeValue = Cmp->getOperand (0 );
7295- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7296- RdxDesc.getRecurrenceKind ())) {
7294+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
72977295 Value *StartV = getStartValueFromReductionResult (EpiRedResult);
72987296 Value *SentinelV = EpiRedResult->getOperand (2 )->getLiveInIRValue ();
72997297 using namespace llvm ::PatternMatch;
@@ -9029,8 +9027,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
90299027 if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
90309028 continue ;
90319029
9032- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9033- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9030+ RecurKind Kind = PhiR->getRecurrenceKind ();
90349031 assert (
90359032 !RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
90369033 !RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9136,6 +9133,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91369133 if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
91379134 CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
91389135
9136+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9137+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91399138 // Non-FP RdxDescs will have all fast math flags set, so clear them.
91409139 FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
91419140 ? RdxDesc.getFastMathFlags ()
@@ -9166,7 +9165,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91669165 if (!PhiR)
91679166 continue ;
91689167
9169- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9168+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9169+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91709170 Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
91719171 // If tail is folded by masking, introduce selects between the phi
91729172 // and the users outside the vector region of each reduction, at the
@@ -9805,14 +9805,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98059805 }));
98069806 ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
98079807 ->getIncomingValueForBlock (L->getLoopPreheader ());
9808- const RecurrenceDescriptor &RdxDesc =
9809- ReductionPhi->getRecurrenceDescriptor ();
9810- RecurKind RK = RdxDesc.getRecurrenceKind ();
9808+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
98119809 if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
98129810 Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9813- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9814- " start value from ComputeAnyOfResult must match" );
9815-
98169811 // VPReductionPHIRecipes for AnyOf reductions expect a boolean as
98179812 // start value; compare the final value from the main vector loop
98189813 // to the start value.
@@ -9821,9 +9816,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98219816 ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
98229817 } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
98239818 Value *StartV = getStartValueFromReductionResult (RdxResult);
9824- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9825- " start value from ComputeFindLastIVResult must match" );
9826-
98279819 ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
98289820 EPI.MainLoopIterationCountCheck );
98299821
0 commit comments