aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2022-10-21 11:18:01 +0100
committerFlorian Hahn <flo@fhahn.com>2022-10-21 11:18:01 +0100
commitfd236772f5665ce9e55f85ac992be6c22a918d3e (patch)
tree1405686cfd7ee198ba471b34335595ebf9381cc3 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parente9754f0211076bab34e5a070cb8eb392a21c0540 (diff)
downloadllvm-fd236772f5665ce9e55f85ac992be6c22a918d3e.zip
llvm-fd236772f5665ce9e55f85ac992be6c22a918d3e.tar.gz
llvm-fd236772f5665ce9e55f85ac992be6c22a918d3e.tar.bz2
[IndVars] Forget SCEV for value after simplifying condition.
Additional SCEV verification highlighted a case where the cached loop dispositions where incorrect after simplifying a condition in IndVars and moving the user in LoopDeletion. Fix it by invalidating ICmp and all its users. Fixes #58515.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 11efcae..9e23fa9 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -289,6 +289,7 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp,
Users.push_back(cast<Instruction>(U));
const Instruction *CtxI = findCommonDominator(Users, *DT);
if (auto Ev = SE->evaluatePredicateAt(Pred, S, X, CtxI)) {
+ SE->forgetValue(ICmp);
ICmp->replaceAllUsesWith(ConstantInt::getBool(ICmp->getContext(), *Ev));
DeadInsts.emplace_back(ICmp);
LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');