@@ -7238,8 +7238,6 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7238
7238
7239
7239
auto *EpiRedHeaderPhi =
7240
7240
cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7241
- const RecurrenceDescriptor &RdxDesc =
7242
- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7243
7241
Value *MainResumeValue;
7244
7242
if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
7245
7243
assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7248,19 +7246,19 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7248
7246
MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7249
7247
} else
7250
7248
MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7251
- if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (
7252
- RdxDesc. getRecurrenceKind () )) {
7249
+ RecurKind Kind = EpiRedHeaderPhi-> getRecurrenceKind ();
7250
+ if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind )) {
7253
7251
Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
7254
7252
(void )StartV;
7253
+
7255
7254
auto *Cmp = cast<ICmpInst>(MainResumeValue);
7256
7255
assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
7257
7256
" AnyOf expected to start with ICMP_NE" );
7258
7257
assert (Cmp->getOperand (1 ) == StartV &&
7259
7258
" AnyOf expected to start by comparing main resume value to original "
7260
7259
" start value" );
7261
7260
MainResumeValue = Cmp->getOperand (0 );
7262
- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7263
- RdxDesc.getRecurrenceKind ())) {
7261
+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
7264
7262
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7265
7263
using namespace llvm ::PatternMatch;
7266
7264
Value *Cmp, *OrigResumeV, *CmpOp;
@@ -9037,8 +9035,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9037
9035
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9038
9036
continue ;
9039
9037
9040
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9041
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9038
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9042
9039
assert (
9043
9040
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9044
9041
!RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9144,6 +9141,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9144
9141
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9145
9142
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9146
9143
9144
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9145
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9147
9146
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9148
9147
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9149
9148
? RdxDesc.getFastMathFlags ()
@@ -9174,7 +9173,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9174
9173
if (!PhiR)
9175
9174
continue ;
9176
9175
9177
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9176
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9177
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9178
9178
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9179
9179
// If tail is folded by masking, introduce selects between the phi
9180
9180
// and the users outside the vector region of each reduction, at the
@@ -9811,14 +9811,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9811
9811
}));
9812
9812
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
9813
9813
->getIncomingValueForBlock (L->getLoopPreheader ());
9814
- const RecurrenceDescriptor &RdxDesc =
9815
- ReductionPhi->getRecurrenceDescriptor ();
9816
- RecurKind RK = RdxDesc.getRecurrenceKind ();
9814
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
9817
9815
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
9818
9816
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9819
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9820
- " start value from ComputeAnyOfResult must match" );
9821
-
9822
9817
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
9823
9818
// start value; compare the final value from the main vector loop
9824
9819
// to the start value.
@@ -9827,9 +9822,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9827
9822
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
9828
9823
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
9829
9824
Value *StartV = getStartValueFromReductionResult (RdxResult);
9830
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9831
- " start value from ComputeFindLastIVResult must match" );
9832
-
9833
9825
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9834
9826
EPI.MainLoopIterationCountCheck );
9835
9827
0 commit comments