@@ -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;
@@ -9040,8 +9037,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9040
9037
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9041
9038
continue ;
9042
9039
9043
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9044
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9040
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9045
9041
assert (
9046
9042
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9047
9043
!RecurrenceDescriptor::isFindIVRecurrenceKind (Kind) &&
@@ -9147,6 +9143,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9147
9143
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9148
9144
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9149
9145
9146
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9147
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9150
9148
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9151
9149
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9152
9150
? RdxDesc.getFastMathFlags ()
@@ -9177,7 +9175,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9177
9175
if (!PhiR)
9178
9176
continue ;
9179
9177
9180
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9178
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9179
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9181
9180
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9182
9181
// If tail is folded by masking, introduce selects between the phi
9183
9182
// and the users outside the vector region of each reduction, at the
@@ -9820,14 +9819,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9820
9819
}));
9821
9820
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
9822
9821
->getIncomingValueForBlock (L->getLoopPreheader ());
9823
- const RecurrenceDescriptor &RdxDesc =
9824
- ReductionPhi->getRecurrenceDescriptor ();
9825
- RecurKind RK = RdxDesc.getRecurrenceKind ();
9822
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
9826
9823
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
9827
9824
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9828
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9829
- " start value from ComputeAnyOfResult must match" );
9830
-
9831
9825
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
9832
9826
// start value; compare the final value from the main vector loop
9833
9827
// to the start value.
@@ -9836,9 +9830,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9836
9830
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
9837
9831
} else if (RecurrenceDescriptor::isFindIVRecurrenceKind (RK)) {
9838
9832
Value *StartV = getStartValueFromReductionResult (RdxResult);
9839
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9840
- " start value from ComputeFinIVResult must match" );
9841
-
9842
9833
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9843
9834
EPI.MainLoopIterationCountCheck );
9844
9835
0 commit comments