Skip to content

Commit 2ed727f

Browse files
committed
[VPlan] Move SCEV invalidation to ::executePlan. (NFCI)
Move SCEV invalidation from legacy ILV code-path directly to ::executePlan.
1 parent b3e3a20 commit 2ed727f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,19 +2633,6 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
26332633
// Fix widened non-induction PHIs by setting up the PHI operands.
26342634
fixNonInductionPHIs(State);
26352635

2636-
// After vectorization, the exit blocks of the original loop will have
2637-
// additional predecessors. Invalidate SCEVs for the exit phis in case SE
2638-
// looked through single-entry phis.
2639-
SmallVector<BasicBlock *> ExitBlocks;
2640-
OrigLoop->getExitBlocks(ExitBlocks);
2641-
for (BasicBlock *Exit : ExitBlocks)
2642-
for (PHINode &PN : Exit->phis())
2643-
PSE.getSE()->forgetLcssaPhiWithNewPredecessor(OrigLoop, &PN);
2644-
2645-
// Forget the original basic block.
2646-
PSE.getSE()->forgetLoop(OrigLoop);
2647-
PSE.getSE()->forgetBlockAndLoopDispositions();
2648-
26492636
// Don't apply optimizations below when no (vector) loop remains, as they all
26502637
// require one at the moment.
26512638
VPBasicBlock *HeaderVPBB =
@@ -7351,6 +7338,21 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
73517338
assert(verifyVPlanIsValid(BestVPlan, true /*VerifyLate*/) &&
73527339
"final VPlan is invalid");
73537340

7341+
// After vectorization, the exit blocks of the original loop will have
7342+
// additional predecessors. Invalidate SCEVs for the exit phis in case SE
7343+
// looked through single-entry phis.
7344+
ScalarEvolution &SE = *PSE.getSE();
7345+
for (VPIRBasicBlock *Exit : BestVPlan.getExitBlocks()) {
7346+
if (Exit->getNumPredecessors() == 0)
7347+
continue;
7348+
for (VPRecipeBase &PhiR : Exit->phis())
7349+
SE.forgetLcssaPhiWithNewPredecessor(
7350+
OrigLoop, cast<PHINode>(&cast<VPIRPhi>(PhiR).getInstruction()));
7351+
}
7352+
// Forget the original loop and block dispositions.
7353+
SE.forgetLoop(OrigLoop);
7354+
SE.forgetBlockAndLoopDispositions();
7355+
73547356
ILV.printDebugTracesAtStart();
73557357

73567358
//===------------------------------------------------===//

0 commit comments

Comments
 (0)