aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <mkazantsev@azul.com>2021-03-18 18:48:10 +0700
committerMax Kazantsev <mkazantsev@azul.com>2021-03-18 19:21:29 +0700
commit1067a13cc11fb7e02b337bc669426bcd5958e86b (patch)
tree9bb2b55569a860e2762d7553fdd5816a2c5bc3ae /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parentb3a1500ea8007c6ecdca6d502aaba0b03a4f705c (diff)
downloadllvm-1067a13cc11fb7e02b337bc669426bcd5958e86b.zip
llvm-1067a13cc11fb7e02b337bc669426bcd5958e86b.tar.gz
llvm-1067a13cc11fb7e02b337bc669426bcd5958e86b.tar.bz2
[NFC] Use evaluatePredicate in eliminateComparison
Just makes code simpler.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 290c04a..d0c43bb 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -263,12 +263,8 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) {
// If the condition is always true or always false, replace it with
// a constant value.
- if (SE->isKnownPredicate(Pred, S, X)) {
- ICmp->replaceAllUsesWith(ConstantInt::getTrue(ICmp->getContext()));
- DeadInsts.emplace_back(ICmp);
- LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');
- } else if (SE->isKnownPredicate(ICmpInst::getInversePredicate(Pred), S, X)) {
- ICmp->replaceAllUsesWith(ConstantInt::getFalse(ICmp->getContext()));
+ if (auto Ev = SE->evaluatePredicate(Pred, S, X)) {
+ ICmp->replaceAllUsesWith(ConstantInt::getBool(ICmp->getContext(), *Ev));
DeadInsts.emplace_back(ICmp);
LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');
} else if (makeIVComparisonInvariant(ICmp, IVOperand)) {