Skip to content

Commit 60c8fae

Browse files
committed
!fixup address latest comments, thanks!
1 parent e4a8918 commit 60c8fae

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7566,8 +7566,7 @@ static void addRuntimeUnrollDisableMetaData(Loop *L) {
75667566
// fix the reduction's scalar PHI node by adding the incoming value from the
75677567
// main vector loop.
75687568
static void fixReductionScalarResumeWhenVectorizingEpilog(
7569-
VPRecipeBase *R, VPTransformState &State, Loop *OrigLoop,
7570-
BasicBlock *LoopMiddleBlock) {
7569+
VPRecipeBase *R, VPTransformState &State, BasicBlock *LoopMiddleBlock) {
75717570
auto *EpiRedResult = dyn_cast<VPInstruction>(R);
75727571
if (!EpiRedResult ||
75737572
EpiRedResult->getOpcode() != VPInstruction::ComputeReductionResult)
@@ -7604,20 +7603,21 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
76047603
auto *EpiResumePhiVPI =
76057604
cast<VPInstruction>(*find_if(EpiRedResult->users(), IsResumePhi));
76067605
auto *EpiResumePhi = cast<PHINode>(State.get(EpiResumePhiVPI, true));
7607-
BasicBlock *LoopScalarPreHeader = OrigLoop->getLoopPreheader();
7608-
unsigned UpdateCnt = 0;
7606+
BasicBlock *LoopScalarPreHeader = EpiResumePhi->getParent();
7607+
bool Updated = false;
76097608
for (auto *Incoming : predecessors(LoopScalarPreHeader)) {
76107609
if (is_contained(MainResumePhi->blocks(), Incoming)) {
76117610
assert(EpiResumePhi->getIncomingValueForBlock(Incoming) ==
76127611
RdxDesc.getRecurrenceStartValue() &&
76137612
"Trying to reset unexpected value");
7613+
assert(!Updated && "Should update at most 1 incoming value");
76147614
EpiResumePhi->setIncomingValueForBlock(
76157615
Incoming, MainResumePhi->getIncomingValueForBlock(Incoming));
7616-
UpdateCnt++;
7616+
Updated = true;
76177617
}
76187618
}
7619-
assert(UpdateCnt <= 1 && "Only should update at most 1 incoming value");
7620-
(void)UpdateCnt;
7619+
assert(Updated && "Must update EpiResumePhi.");
7620+
(void)Updated;
76217621
}
76227622

76237623
DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
@@ -7711,7 +7711,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
77117711
if (VectorizingEpilogue)
77127712
for (VPRecipeBase &R : *ExitVPBB) {
77137713
fixReductionScalarResumeWhenVectorizingEpilog(
7714-
&R, State, OrigLoop, State.CFG.VPBB2IRBB[ExitVPBB]);
7714+
&R, State, State.CFG.VPBB2IRBB[ExitVPBB]);
77157715
}
77167716

77177717
// 2.6. Maintain Loop Hints

0 commit comments

Comments
 (0)