@@ -676,11 +676,6 @@ class InnerLoopVectorizer {
676
676
/// Structure to hold information about generated runtime checks, responsible
677
677
/// for cleaning the checks, if vectorization turns out unprofitable.
678
678
GeneratedRTChecks &RTChecks;
679
-
680
- // Holds the resume values for reductions in the loops, used to set the
681
- // correct start value of reduction PHIs when vectorizing the epilogue.
682
- SmallMapVector<const RecurrenceDescriptor *, PHINode *, 4>
683
- ReductionResumeValues;
684
679
};
685
680
686
681
/// Encapsulate information regarding vectorization of a loop and its epilogue.
@@ -7426,10 +7421,9 @@ static void addRuntimeUnrollDisableMetaData(Loop *L) {
7426
7421
}
7427
7422
7428
7423
// Check if \p RedResult is a ComputeReductionResult instruction, and if it is
7429
- // create a merge phi node for it and add it to \p ReductionResumeValues .
7424
+ // create a merge phi node for it.
7430
7425
static void createAndCollectMergePhiForReduction(
7431
7426
VPInstruction *RedResult,
7432
- DenseMap<const RecurrenceDescriptor *, Value *> &ReductionResumeValues,
7433
7427
VPTransformState &State, Loop *OrigLoop, BasicBlock *LoopMiddleBlock,
7434
7428
bool VectorizingEpilogue) {
7435
7429
if (!RedResult ||
@@ -7487,13 +7481,9 @@ static void createAndCollectMergePhiForReduction(
7487
7481
OrigPhi->setIncomingValue(SelfEdgeBlockIdx, BCBlockPhi);
7488
7482
Instruction *LoopExitInst = RdxDesc.getLoopExitInstr();
7489
7483
OrigPhi->setIncomingValue(IncomingEdgeBlockIdx, LoopExitInst);
7490
-
7491
- ReductionResumeValues[&RdxDesc] = BCBlockPhi;
7492
7484
}
7493
7485
7494
- std::pair<DenseMap<const SCEV *, Value *>,
7495
- DenseMap<const RecurrenceDescriptor *, Value *>>
7496
- LoopVectorizationPlanner::executePlan(
7486
+ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7497
7487
ElementCount BestVF, unsigned BestUF, VPlan &BestVPlan,
7498
7488
InnerLoopVectorizer &ILV, DominatorTree *DT, bool IsEpilogueVectorization,
7499
7489
const DenseMap<const SCEV *, Value *> *ExpandedSCEVs) {
@@ -7579,12 +7569,11 @@ LoopVectorizationPlanner::executePlan(
7579
7569
BestVPlan.execute(&State);
7580
7570
7581
7571
// 2.5 Collect reduction resume values.
7582
- DenseMap<const RecurrenceDescriptor *, Value *> ReductionResumeValues;
7583
7572
auto *ExitVPBB =
7584
7573
cast<VPBasicBlock>(BestVPlan.getVectorLoopRegion()->getSingleSuccessor());
7585
7574
for (VPRecipeBase &R : *ExitVPBB) {
7586
7575
createAndCollectMergePhiForReduction(
7587
- dyn_cast<VPInstruction>(&R), ReductionResumeValues, State, OrigLoop,
7576
+ dyn_cast<VPInstruction>(&R), State, OrigLoop,
7588
7577
State.CFG.VPBB2IRBB[ExitVPBB], ExpandedSCEVs);
7589
7578
}
7590
7579
@@ -7634,7 +7623,7 @@ LoopVectorizationPlanner::executePlan(
7634
7623
setBranchWeights(*MiddleTerm, Weights, /*IsExpected=*/false);
7635
7624
}
7636
7625
7637
- return { State.ExpandedSCEVs, ReductionResumeValues} ;
7626
+ return State.ExpandedSCEVs;
7638
7627
}
7639
7628
7640
7629
//===--------------------------------------------------------------------===//
@@ -10121,8 +10110,8 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10121
10110
EPI, &LVL, &CM, BFI, PSI, Checks);
10122
10111
10123
10112
std::unique_ptr<VPlan> BestMainPlan(BestPlan.duplicate());
10124
- const auto &[ ExpandedSCEVs, ReductionResumeValues] = LVP.executePlan(
10125
- EPI.MainLoopVF, EPI.MainLoopUF, *BestMainPlan, MainILV, DT, true);
10113
+ auto ExpandedSCEVs = LVP.executePlan(EPI.MainLoopVF, EPI.MainLoopUF,
10114
+ *BestMainPlan, MainILV, DT, true);
10126
10115
++LoopsVectorized;
10127
10116
10128
10117
// Second pass vectorizes the epilogue and adjusts the control flow
@@ -10167,10 +10156,11 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10167
10156
Value *ResumeV = nullptr;
10168
10157
// TODO: Move setting of resume values to prepareToExecute.
10169
10158
if (auto *ReductionPhi = dyn_cast<VPReductionPHIRecipe>(&R)) {
10159
+ ResumeV = cast<PHINode>(ReductionPhi->getUnderlyingInstr())
10160
+ ->getIncomingValueForBlock(L->getLoopPreheader());
10170
10161
const RecurrenceDescriptor &RdxDesc =
10171
10162
ReductionPhi->getRecurrenceDescriptor();
10172
10163
RecurKind RK = RdxDesc.getRecurrenceKind();
10173
- ResumeV = ReductionResumeValues.find(&RdxDesc)->second;
10174
10164
if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RK)) {
10175
10165
// VPReductionPHIRecipes for AnyOf reductions expect a boolean as
10176
10166
// start value; compare the final value from the main vector loop
0 commit comments