@@ -7233,8 +7233,6 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7233
7233
7234
7234
auto *EpiRedHeaderPhi =
7235
7235
cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7236
- const RecurrenceDescriptor &RdxDesc =
7237
- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7238
7236
Value *MainResumeValue;
7239
7237
if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ())) {
7240
7238
assert ((VPI->getOpcode () == VPInstruction::Broadcast ||
@@ -7243,19 +7241,19 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7243
7241
MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7244
7242
} else
7245
7243
MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7246
- if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (
7247
- RdxDesc. getRecurrenceKind () )) {
7244
+ RecurKind Kind = EpiRedHeaderPhi-> getRecurrenceKind ();
7245
+ if ( RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind )) {
7248
7246
Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
7249
7247
(void )StartV;
7248
+
7250
7249
auto *Cmp = cast<ICmpInst>(MainResumeValue);
7251
7250
assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
7252
7251
" AnyOf expected to start with ICMP_NE" );
7253
7252
assert (Cmp->getOperand (1 ) == StartV &&
7254
7253
" AnyOf expected to start by comparing main resume value to original "
7255
7254
" start value" );
7256
7255
MainResumeValue = Cmp->getOperand (0 );
7257
- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7258
- RdxDesc.getRecurrenceKind ())) {
7256
+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
7259
7257
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7260
7258
using namespace llvm ::PatternMatch;
7261
7259
Value *Cmp, *OrigResumeV, *CmpOp;
@@ -9050,8 +9048,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9050
9048
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9051
9049
continue ;
9052
9050
9053
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9054
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9051
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9055
9052
assert (
9056
9053
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9057
9054
!RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9157,6 +9154,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9157
9154
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9158
9155
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9159
9156
9157
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9158
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9160
9159
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9161
9160
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9162
9161
? RdxDesc.getFastMathFlags ()
@@ -9187,7 +9186,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9187
9186
if (!PhiR)
9188
9187
continue ;
9189
9188
9190
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9189
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9190
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9191
9191
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9192
9192
// If tail is folded by masking, introduce selects between the phi
9193
9193
// and the users outside the vector region of each reduction, at the
@@ -9824,14 +9824,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9824
9824
}));
9825
9825
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
9826
9826
->getIncomingValueForBlock (L->getLoopPreheader ());
9827
- const RecurrenceDescriptor &RdxDesc =
9828
- ReductionPhi->getRecurrenceDescriptor ();
9829
- RecurKind RK = RdxDesc.getRecurrenceKind ();
9827
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
9830
9828
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
9831
9829
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9832
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9833
- " start value from ComputeAnyOfResult must match" );
9834
-
9835
9830
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
9836
9831
// start value; compare the final value from the main vector loop
9837
9832
// to the start value.
@@ -9840,9 +9835,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9840
9835
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
9841
9836
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
9842
9837
Value *StartV = getStartValueFromReductionResult (RdxResult);
9843
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9844
- " start value from ComputeFindLastIVResult must match" );
9845
-
9846
9838
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9847
9839
EPI.MainLoopIterationCountCheck );
9848
9840
0 commit comments