@@ -7507,26 +7507,21 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7507
7507
7508
7508
auto *EpiRedHeaderPhi =
7509
7509
cast<VPReductionPHIRecipe>(EpiRedResult->getOperand (0 ));
7510
- const RecurrenceDescriptor &RdxDesc =
7511
- EpiRedHeaderPhi->getRecurrenceDescriptor ();
7512
- Value *MainResumeValue;
7513
- if (auto *VPI = dyn_cast<VPInstruction>(EpiRedHeaderPhi->getStartValue ()))
7514
- MainResumeValue = VPI->getOperand (0 )->getUnderlyingValue ();
7515
- else
7516
- MainResumeValue = EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7517
- if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
7518
- RdxDesc.getRecurrenceKind ())) {
7510
+ RecurKind Kind = EpiRedHeaderPhi->getRecurrenceKind ();
7511
+ Value *MainResumeValue =
7512
+ EpiRedHeaderPhi->getStartValue ()->getUnderlyingValue ();
7513
+ if (RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind)) {
7519
7514
Value *StartV = EpiRedResult->getOperand (1 )->getLiveInIRValue ();
7520
7515
(void )StartV;
7516
+
7521
7517
auto *Cmp = cast<ICmpInst>(MainResumeValue);
7522
7518
assert (Cmp->getPredicate () == CmpInst::ICMP_NE &&
7523
7519
" AnyOf expected to start with ICMP_NE" );
7524
7520
assert (Cmp->getOperand (1 ) == StartV &&
7525
7521
" AnyOf expected to start by comparing main resume value to original "
7526
7522
" start value" );
7527
7523
MainResumeValue = Cmp->getOperand (0 );
7528
- } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7529
- RdxDesc.getRecurrenceKind ())) {
7524
+ } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind)) {
7530
7525
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7531
7526
(void )StartV;
7532
7527
using namespace llvm ::PatternMatch;
@@ -9323,8 +9318,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9323
9318
if (!PhiR || !PhiR->isInLoop () || (MinVF.isScalar () && !PhiR->isOrdered ()))
9324
9319
continue ;
9325
9320
9326
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9327
- RecurKind Kind = RdxDesc.getRecurrenceKind ();
9321
+ RecurKind Kind = PhiR->getRecurrenceKind ();
9328
9322
assert (
9329
9323
!RecurrenceDescriptor::isAnyOfRecurrenceKind (Kind) &&
9330
9324
!RecurrenceDescriptor::isFindLastIVRecurrenceKind (Kind) &&
@@ -9430,6 +9424,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9430
9424
if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
9431
9425
CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
9432
9426
9427
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9428
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9433
9429
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9434
9430
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9435
9431
? RdxDesc.getFastMathFlags ()
@@ -9460,7 +9456,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9460
9456
if (!PhiR)
9461
9457
continue ;
9462
9458
9463
- const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
9459
+ const RecurrenceDescriptor &RdxDesc = Legal->getReductionVars ().lookup (
9460
+ cast<PHINode>(PhiR->getUnderlyingInstr ()));
9464
9461
Type *PhiTy = PhiR->getUnderlyingValue ()->getType ();
9465
9462
// If tail is folded by masking, introduce selects between the phi
9466
9463
// and the users outside the vector region of each reduction, at the
@@ -10106,14 +10103,9 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
10106
10103
}));
10107
10104
ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr ())
10108
10105
->getIncomingValueForBlock (L->getLoopPreheader ());
10109
- const RecurrenceDescriptor &RdxDesc =
10110
- ReductionPhi->getRecurrenceDescriptor ();
10111
- RecurKind RK = RdxDesc.getRecurrenceKind ();
10106
+ RecurKind RK = ReductionPhi->getRecurrenceKind ();
10112
10107
if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RK)) {
10113
10108
Value *StartV = RdxResult->getOperand (1 )->getLiveInIRValue ();
10114
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
10115
- " start value from ComputeAnyOfResult must match" );
10116
-
10117
10109
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
10118
10110
// start value; compare the final value from the main vector loop
10119
10111
// to the start value.
@@ -10122,9 +10114,6 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
10122
10114
ResumeV = Builder.CreateICmpNE (ResumeV, StartV);
10123
10115
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK)) {
10124
10116
Value *StartV = getStartValueFromReductionResult (RdxResult);
10125
- assert (RdxDesc.getRecurrenceStartValue () == StartV &&
10126
- " start value from ComputeFindLastIVResult must match" );
10127
-
10128
10117
ToFrozen[StartV] = cast<PHINode>(ResumeV)->getIncomingValueForBlock (
10129
10118
EPI.MainLoopIterationCountCheck );
10130
10119
0 commit comments