diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2017-07-05 06:38:49 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2017-07-05 06:38:49 +0000 |
commit | 80bc4a5554226f1f4a14ea204acf1ae2cac6bbb2 (patch) | |
tree | 0a2dd4fcd34b51ad257a95481fbf09f4fd698fa8 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | 9d5571a2269277af458ca7c93e5afc019d09695c (diff) | |
download | llvm-80bc4a5554226f1f4a14ea204acf1ae2cac6bbb2.zip llvm-80bc4a5554226f1f4a14ea204acf1ae2cac6bbb2.tar.gz llvm-80bc4a5554226f1f4a14ea204acf1ae2cac6bbb2.tar.bz2 |
[IndVars] Canonicalize comparisons between non-negative values and indvars
-If there is a IndVar which is known to be non-negative, and there is a value which is also non-negative,
then signed and unsigned comparisons between them produce the same result. Both of those can be
seen in the same loop. To allow other optimizations to simplify them, we turn all instructions like
%c = icmp slt i32 %iv, %b
to
%c = icmp ult i32 %iv, %b
if both %iv and %b are known to be non-negative.
Differential Revision: https://reviews.llvm.org/D34979
llvm-svn: 307126
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index ec8b0d4..77f035a 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -262,6 +262,10 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) { ICmp->setPredicate(InvariantPredicate); ICmp->setOperand(0, NewLHS); ICmp->setOperand(1, NewRHS); + } else if (ICmpInst::isSigned(Pred) && + SE->isKnownNonNegative(S) && SE->isKnownNonNegative(X)) { + DEBUG(dbgs() << "INDVARS: Turn to unsigned comparison: " << *ICmp << '\n'); + ICmp->setPredicate(ICmpInst::getUnsignedPredicate(Pred)); } else return; |