Index: lib/Transforms/Scalar/LoopSimplifyCFG.cpp =================================================================== --- lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -61,7 +61,12 @@ // Merge Succ into Pred and delete it. MergeBlockIntoPredecessor(Succ, &DTU, &LI); + // Deleted block Succ was part of loop L and all its parent loops. SE.forgetLoop(&L); + auto *LoopForget = &L; + while ((LoopForget = LoopForget->getParentLoop())) + SE.forgetLoop(LoopForget); + Changed = true; }