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