diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopPeel.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopPeel.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp index bd025fd..9149f71 100644 --- a/llvm/lib/Transforms/Utils/LoopPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp @@ -1257,7 +1257,11 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI, // Now adjust users of the original exit values by replacing them with the // exit value from the peeled iteration and remove them. for (const auto &[P, E] : ExitValues) { - P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E)); + Instruction *ExitInst = dyn_cast<Instruction>(E); + if (ExitInst && L->contains(ExitInst)) + P->replaceAllUsesWith(&*VMap[ExitInst]); + else + P->replaceAllUsesWith(E); P->eraseFromParent(); } formLCSSA(*L, DT, LI, SE); |