[llvm-commits] [llvm] r123515 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 14 21:41:33 PST 2011
Author: lattner
Date: Fri Jan 14 23:41:33 2011
New Revision: 123515
URL: http://llvm.org/viewvc/llvm-project?rev=123515&view=rev
Log:
Catch ~x < cst just like ~x < ~y, we currently handle this through
means that are about to disappear.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=123515&r1=123514&r2=123515&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Fri Jan 14 23:41:33 2011
@@ -2284,11 +2284,15 @@
}
}
- // ~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.
More information about the llvm-commits
mailing list