@@ -7272,8 +7272,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7272
7272
7273
7273
auto *EpiRedHeaderPhi =
7274
7274
cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7275
- const RecurrenceDescriptor &RdxDesc =
7276
- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7275
+ RecurKind Kind = EpiRedHeaderPhi->getRecurrenceKind ();
7277
7276
Value *MainResumeValue;
7278
7277
if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
7279
7278
assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7282,8 +7281,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7282
7281
MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7283
7282
} else
7284
7283
MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7285
- if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
7286
- RdxDesc.getRecurrenceKind ())) {
7284
+ if (RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind)) {
7287
7285
Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
7288
7286
(void )StartV;
7289
7287
auto *Cmp = cast<ICmpInst>(MainResumeValue);
@@ -7293,8 +7291,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7293
7291
" AnyOf expected to start by comparing main resume value to original "
7294
7292
" start value" );
7295
7293
MainResumeValue = Cmp->getOperand (0 );
7296
- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7297
- RdxDesc.getRecurrenceKind ())) {
7294
+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
7298
7295
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7299
7296
Value *SentinelV = EpiRedResult->getOperand (2 )->getLiveInIRValue ();
7300
7297
using namespace llvm ::PatternMatch;
@@ -9045,8 +9042,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9045
9042
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9046
9043
continue ;
9047
9044
9048
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9049
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9045
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9050
9046
assert (
9051
9047
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9052
9048
!RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9152,6 +9148,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9152
9148
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9153
9149
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9154
9150
9151
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9152
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9155
9153
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9156
9154
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9157
9155
? RdxDesc.getFastMathFlags ()
@@ -9182,7 +9180,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9182
9180
if (!PhiR)
9183
9181
continue ;
9184
9182
9185
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9183
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9184
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9186
9185
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9187
9186
// If tail is folded by masking, introduce selects between the phi
9188
9187
// 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::isFindLastIVRecurrenceKind (RK)) {
9843
9837
Value *StartV = getStartValueFromReductionResult (RdxResult);
9844
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9845
- " start value from ComputeFindLastIVResult must match" );
9846
-
9847
9838
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9848
9839
EPI.MainLoopIterationCountCheck );
9849
9840
0 commit comments