@@ -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
@@ -9833,14 +9833,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9833
9833
}));
9834
9834
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
9835
9835
->getIncomingValueForBlock (L->getLoopPreheader ());
9836
- const RecurrenceDescriptor &RdxDesc =
9837
- ReductionPhi->getRecurrenceDescriptor ();
9838
- RecurKind RK = RdxDesc.getRecurrenceKind ();
9836
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
9839
9837
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
9840
9838
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
9841
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9842
- " start value from ComputeAnyOfResult must match" );
9843
-
9844
9839
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
9845
9840
// start value; compare the final value from the main vector loop
9846
9841
// to the start value.
@@ -9849,9 +9844,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9849
9844
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
9850
9845
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
9851
9846
Value *StartV = getStartValueFromReductionResult (RdxResult);
9852
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
9853
- " start value from ComputeFindLastIVResult must match" );
9854
-
9855
9847
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
9856
9848
EPI.MainLoopIterationCountCheck );
9857
9849
0 commit comments