@@ -2633,19 +2633,6 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
2633
2633
// Fix widened non-induction PHIs by setting up the PHI operands.
2634
2634
fixNonInductionPHIs (State);
2635
2635
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
-
2649
2636
// Don't apply optimizations below when no (vector) loop remains, as they all
2650
2637
// require one at the moment.
2651
2638
VPBasicBlock *HeaderVPBB =
@@ -7351,6 +7338,21 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7351
7338
assert (verifyVPlanIsValid (BestVPlan, true /* VerifyLate*/ ) &&
7352
7339
" final VPlan is invalid" );
7353
7340
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
+
7354
7356
ILV.printDebugTracesAtStart ();
7355
7357
7356
7358
// ===------------------------------------------------===//
0 commit comments