aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <mkazantsev@azul.com>2022-08-12 13:27:01 +0700
committerMax Kazantsev <mkazantsev@azul.com>2022-08-12 14:23:35 +0700
commita3d1fb3b59b473e4f262a05f187de6474b7721e7 (patch)
tree8e8995fd72cb135c7a887ec92bbd962b6ed8e489 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent90736babcaeb5222ee5ba50a823b7acffdd5a4dd (diff)
downloadllvm-a3d1fb3b59b473e4f262a05f187de6474b7721e7.zip
llvm-a3d1fb3b59b473e4f262a05f187de6474b7721e7.tar.gz
llvm-a3d1fb3b59b473e4f262a05f187de6474b7721e7.tar.bz2
[SCEV] Prove condition invariance via context
Contextual knowledge may be used to prove invariance of some conditions. For example, in this case: ``` ; %len >= 0 guard(%iv = {start,+,1}<nuw> <s %len) guard(%iv = {start,+,1}<nuw> <u %len) ``` the 2nd check always fails if `start` is negative and always passes otherwise. It looks like there are more opportunities of this kind that are still to be implemented in the future. Differential Revision: https://reviews.llvm.org/D129753 Reviewed By: apilipenko
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 0a856ee..08c48b0 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -213,7 +213,8 @@ bool SimplifyIndvar::makeIVComparisonInvariant(ICmpInst *ICmp,
auto *PN = dyn_cast<PHINode>(IVOperand);
if (!PN)
return false;
- auto LIP = SE->getLoopInvariantPredicate(Pred, S, X, L);
+
+ auto LIP = SE->getLoopInvariantPredicate(Pred, S, X, L, ICmp);
if (!LIP)
return false;
ICmpInst::Predicate InvariantPredicate = LIP->Pred;