@@ -7507,26 +7507,21 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
75077507
75087508  auto  *EpiRedHeaderPhi =
75097509      cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7510-   const  RecurrenceDescriptor &RdxDesc =
7511-       EpiRedHeaderPhi->getRecurrenceDescriptor ();
7512-   Value *MainResumeValue;
7513-   if  (auto  *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ()))
7514-     MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7515-   else 
7516-     MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7517-   if  (RecurrenceDescriptor::isAnyOfRecurrenceKind (
7518-           RdxDesc.getRecurrenceKind ())) {
7510+   RecurKind Kind = EpiRedHeaderPhi->getRecurrenceKind ();
7511+   Value *MainResumeValue =
7512+       EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7513+   if  (RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind)) {
75197514    Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
75207515    (void )StartV;
7516+ 
75217517    auto  *Cmp = cast<ICmpInst>(MainResumeValue);
75227518    assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
75237519           " AnyOf expected to start with ICMP_NE"  );
75247520    assert (Cmp->getOperand (1 ) == StartV &&
75257521           " AnyOf expected to start by comparing main resume value to original " 
75267522           " start value"  );
75277523    MainResumeValue = Cmp->getOperand (0 );
7528-   } else  if  (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7529-                  RdxDesc.getRecurrenceKind ())) {
7524+   } else  if  (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
75307525    Value *StartV = getStartValueFromReductionResult (EpiRedResult);
75317526    (void )StartV;
75327527    using  namespace  llvm ::PatternMatch; 
@@ -9323,8 +9318,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
93239318    if  (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
93249319      continue ;
93259320
9326-     const  RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9327-     RecurKind Kind = RdxDesc.getRecurrenceKind ();
9321+     RecurKind Kind = PhiR->getRecurrenceKind ();
93289322    assert (
93299323        !RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
93309324        !RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9430,6 +9424,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
94309424      if  (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
94319425        CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
94329426
9427+       const  RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9428+           cast<PHINode>(PhiR->getUnderlyingInstr ()));
94339429      //  Non-FP RdxDescs will have all fast math flags set, so clear them.
94349430      FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
94359431                               ? RdxDesc.getFastMathFlags ()
@@ -9460,7 +9456,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
94609456    if  (!PhiR)
94619457      continue ;
94629458
9463-     const  RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9459+     const  RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9460+         cast<PHINode>(PhiR->getUnderlyingInstr ()));
94649461    Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
94659462    //  If tail is folded by masking, introduce selects between the phi
94669463    //  and the users outside the vector region of each reduction, at the
@@ -10106,14 +10103,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
1010610103          }));
1010710104      ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
1010810105                    ->getIncomingValueForBlock (L->getLoopPreheader ());
10109-       const  RecurrenceDescriptor &RdxDesc =
10110-           ReductionPhi->getRecurrenceDescriptor ();
10111-       RecurKind RK = RdxDesc.getRecurrenceKind ();
10106+       RecurKind RK = ReductionPhi->getRecurrenceKind ();
1011210107      if  (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
1011310108        Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
10114-         assert (RdxDesc.getRecurrenceStartValue () == StartV &&
10115-                " start value from ComputeAnyOfResult must match"  );
10116- 
1011710109        //  VPReductionPHIRecipes for AnyOf reductions expect a boolean as
1011810110        //  start value; compare the final value from the main vector loop
1011910111        //  to the start value.
@@ -10122,9 +10114,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
1012210114        ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
1012310115      } else  if  (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
1012410116        Value *StartV = getStartValueFromReductionResult (RdxResult);
10125-         assert (RdxDesc.getRecurrenceStartValue () == StartV &&
10126-                " start value from ComputeFindLastIVResult must match"  );
10127- 
1012810117        ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
1012910118            EPI.MainLoopIterationCountCheck );
1013010119
0 commit comments