aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/InstCombine/InstCombineCompares.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-15 05:41:33 +0000
committerChris Lattner <sabre@nondot.org>2011-01-15 05:41:33 +0000
commitfdb5b01df486f8fca44927a38dc9763e9d538e4c (patch)
tree9dc5db6d18a00ec27524e60a999243865270b42c /lib/Transforms/InstCombine/InstCombineCompares.cpp
parent28621cb36f1d5c761dc5b493c501b4c7252fe5dc (diff)
downloadexternal_llvm-fdb5b01df486f8fca44927a38dc9763e9d538e4c.zip
external_llvm-fdb5b01df486f8fca44927a38dc9763e9d538e4c.tar.gz
external_llvm-fdb5b01df486f8fca44927a38dc9763e9d538e4c.tar.bz2
Catch ~x < cst just like ~x < ~y, we currently handle this through
means that are about to disappear. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index bd33974..2206016 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2284,11 +2284,15 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
}
}
- // ~x < ~y --> y < x
{ Value *A, *B;
- if (match(Op0, m_Not(m_Value(A))) &&
- match(Op1, m_Not(m_Value(B))))
- return new ICmpInst(I.getPredicate(), B, A);
+ // ~x < ~y --> y < x
+ // ~x < cst --> ~cst < x
+ if (match(Op0, m_Not(m_Value(A)))) {
+ if (match(Op1, m_Not(m_Value(B))))
+ return new ICmpInst(I.getPredicate(), B, A);
+ if (ConstantInt *RHSC = dyn_cast<ConstantInt>(B))
+ return new ICmpInst(I.getPredicate(), ConstantExpr::getNot(RHSC), A);
+ }
// (a+b) <u a --> llvm.uadd.with.overflow.
// (a+b) <u b --> llvm.uadd.with.overflow.