@@ -7271,8 +7271,6 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7271
7271
7272
7272
auto *EpiRedHeaderPhi =
7273
7273
cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7274
- const RecurrenceDescriptor &RdxDesc =
7275
- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7276
7274
Value *MainResumeValue;
7277
7275
if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
7278
7276
assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7281,19 +7279,19 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7281
7279
MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7282
7280
} else
7283
7281
MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7284
- if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (
7285
- RdxDesc. getRecurrenceKind () )) {
7282
+ RecurKind Kind = EpiRedHeaderPhi-> getRecurrenceKind ();
7283
+ if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind )) {
7286
7284
Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
7287
7285
(void )StartV;
7286
+
7288
7287
auto *Cmp = cast<ICmpInst>(MainResumeValue);
7289
7288
assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
7290
7289
" AnyOf expected to start with ICMP_NE" );
7291
7290
assert (Cmp->getOperand (1 ) == StartV &&
7292
7291
" AnyOf expected to start by comparing main resume value to original "
7293
7292
" start value" );
7294
7293
MainResumeValue = Cmp->getOperand (0 );
7295
- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7296
- RdxDesc.getRecurrenceKind ())) {
7294
+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
7297
7295
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7298
7296
Value *SentinelV = EpiRedResult->getOperand (2 )->getLiveInIRValue ();
7299
7297
using namespace llvm ::PatternMatch;
@@ -9029,8 +9027,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9029
9027
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9030
9028
continue ;
9031
9029
9032
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9033
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9030
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9034
9031
assert (
9035
9032
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9036
9033
!RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9136,6 +9133,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9136
9133
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9137
9134
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9138
9135
9136
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9137
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9139
9138
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9140
9139
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9141
9140
? RdxDesc.getFastMathFlags ()
@@ -9166,7 +9165,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9166
9165
if (!PhiR)
9167
9166
continue ;
9168
9167
9169
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9168
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9169
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9170
9170
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9171
9171
// If tail is folded by masking, introduce selects between the phi
9172
9172
// and the users outside the vector region of each reduction, at the
@@ -9805,14 +9805,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9805
9805
}));
9806
9806
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
9807
9807
->getIncomingValueForBlock (L->getLoopPreheader ());
9808
- const RecurrenceDescriptor &RdxDesc =
9809
- ReductionPhi->getRecurrenceDescriptor ();
9810
- RecurKind RK = RdxDesc.getRecurrenceKind ();
9808
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
9811
9809
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
9812
9810
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9813
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9814
- " start value from ComputeAnyOfResult must match" );
9815
-
9816
9811
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
9817
9812
// start value; compare the final value from the main vector loop
9818
9813
// to the start value.
@@ -9821,9 +9816,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9821
9816
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
9822
9817
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
9823
9818
Value *StartV = getStartValueFromReductionResult (RdxResult);
9824
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9825
- " start value from ComputeFindLastIVResult must match" );
9826
-
9827
9819
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9828
9820
EPI.MainLoopIterationCountCheck );
9829
9821
0 commit comments