@@ -7233,8 +7233,6 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72337233
72347234 auto *EpiRedHeaderPhi =
72357235 cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7236- const RecurrenceDescriptor &RdxDesc =
7237- EpiRedHeaderPhi->getRecurrenceDescriptor ();
72387236 Value *MainResumeValue;
72397237 if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
72407238 assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7243,19 +7241,19 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
72437241 MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
72447242 } else
72457243 MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7246- if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (
7247- RdxDesc. getRecurrenceKind () )) {
7244+ RecurKind Kind = EpiRedHeaderPhi-> getRecurrenceKind ();
7245+ if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind )) {
72487246 Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
72497247 (void )StartV;
7248+
72507249 auto *Cmp = cast<ICmpInst>(MainResumeValue);
72517250 assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
72527251 " AnyOf expected to start with ICMP_NE" );
72537252 assert (Cmp->getOperand (1 ) == StartV &&
72547253 " AnyOf expected to start by comparing main resume value to original "
72557254 " start value" );
72567255 MainResumeValue = Cmp->getOperand (0 );
7257- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7258- RdxDesc.getRecurrenceKind ())) {
7256+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
72597257 Value *StartV = getStartValueFromReductionResult (EpiRedResult);
72607258 using namespace llvm ::PatternMatch;
72617259 Value *Cmp, *OrigResumeV, *CmpOp;
@@ -9050,8 +9048,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
90509048 if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
90519049 continue ;
90529050
9053- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9054- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9051+ RecurKind Kind = PhiR->getRecurrenceKind ();
90559052 assert (
90569053 !RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
90579054 !RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9157,6 +9154,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91579154 if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
91589155 CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
91599156
9157+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9158+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91609159 // Non-FP RdxDescs will have all fast math flags set, so clear them.
91619160 FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
91629161 ? RdxDesc.getFastMathFlags ()
@@ -9187,7 +9186,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91879186 if (!PhiR)
91889187 continue ;
91899188
9190- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9189+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9190+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
91919191 Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
91929192 // If tail is folded by masking, introduce selects between the phi
91939193 // and the users outside the vector region of each reduction, at the
@@ -9824,14 +9824,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98249824 }));
98259825 ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
98269826 ->getIncomingValueForBlock (L->getLoopPreheader ());
9827- const RecurrenceDescriptor &RdxDesc =
9828- ReductionPhi->getRecurrenceDescriptor ();
9829- RecurKind RK = RdxDesc.getRecurrenceKind ();
9827+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
98309828 if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
98319829 Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9832- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9833- " start value from ComputeAnyOfResult must match" );
9834-
98359830 // VPReductionPHIRecipes for AnyOf reductions expect a boolean as
98369831 // start value; compare the final value from the main vector loop
98379832 // to the start value.
@@ -9840,9 +9835,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98409835 ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
98419836 } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
98429837 Value *StartV = getStartValueFromReductionResult (RdxResult);
9843- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9844- " start value from ComputeFindLastIVResult must match" );
9845-
98469838 ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
98479839 EPI.MainLoopIterationCountCheck );
98489840
0 commit comments