@@ -7267,8 +7267,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7267
7267
7268
7268
auto *EpiRedHeaderPhi =
7269
7269
cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7270
- const RecurrenceDescriptor &RdxDesc =
7271
- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7270
+ RecurKind Kind = EpiRedHeaderPhi->getRecurrenceKind ();
7272
7271
Value *MainResumeValue;
7273
7272
if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
7274
7273
assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7277,8 +7276,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7277
7276
MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7278
7277
} else
7279
7278
MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7280
- if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
7281
- RdxDesc.getRecurrenceKind ())) {
7279
+ if (RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind)) {
7282
7280
[[maybe_unused]] Value *StartV =
7283
7281
EpiRedResult->getOperand (1 )->getLiveInIRValue ();
7284
7282
auto *Cmp = cast<ICmpInst>(MainResumeValue);
@@ -7288,8 +7286,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7288
7286
" AnyOf expected to start by comparing main resume value to original "
7289
7287
" start value" );
7290
7288
MainResumeValue = Cmp->getOperand (0 );
7291
- } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (
7292
- RdxDesc.getRecurrenceKind ())) {
7289
+ } else if (RecurrenceDescriptor::isFindIVRecurrenceKind (Kind)) {
7293
7290
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7294
7291
Value *SentinelV = EpiRedResult->getOperand (2 )->getLiveInIRValue ();
7295
7292
using namespace llvm ::PatternMatch;
@@ -9070,8 +9067,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9070
9067
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9071
9068
continue ;
9072
9069
9073
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9074
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9070
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9075
9071
assert (
9076
9072
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9077
9073
!RecurrenceDescriptor::isFindIVRecurrenceKind (Kind) &&
@@ -9177,6 +9173,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9177
9173
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9178
9174
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9179
9175
9176
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9177
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9180
9178
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9181
9179
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9182
9180
? RdxDesc.getFastMathFlags ()
@@ -9207,7 +9205,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9207
9205
if (!PhiR)
9208
9206
continue ;
9209
9207
9210
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9208
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9209
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9211
9210
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9212
9211
// If tail is folded by masking, introduce selects between the phi
9213
9212
// and the users outside the vector region of each reduction, at the
@@ -9853,14 +9852,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9853
9852
}));
9854
9853
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
9855
9854
->getIncomingValueForBlock (L->getLoopPreheader ());
9856
- const RecurrenceDescriptor &RdxDesc =
9857
- ReductionPhi->getRecurrenceDescriptor ();
9858
- RecurKind RK = RdxDesc.getRecurrenceKind ();
9855
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
9859
9856
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
9860
9857
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9861
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9862
- " start value from ComputeAnyOfResult must match" );
9863
-
9864
9858
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
9865
9859
// start value; compare the final value from the main vector loop
9866
9860
// to the start value.
@@ -9869,9 +9863,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9869
9863
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
9870
9864
} else if (RecurrenceDescriptor::isFindIVRecurrenceKind (RK)) {
9871
9865
Value *StartV = getStartValueFromReductionResult (RdxResult);
9872
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9873
- " start value from ComputeFinIVResult must match" );
9874
-
9875
9866
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9876
9867
EPI.MainLoopIterationCountCheck );
9877
9868
0 commit comments