From: Chris Lattner Date: Sat, 15 Jan 2011 05:41:33 +0000 (+0000) Subject: Catch ~x < cst just like ~x < ~y, we currently handle this through X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=fdb5b01df486f8fca44927a38dc9763e9d538e4c;p=oota-llvm.git 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 --- diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index bd339742ef2..220601611d7 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(B)) + return new ICmpInst(I.getPredicate(), ConstantExpr::getNot(RHSC), A); + } // (a+b) llvm.uadd.with.overflow. // (a+b) llvm.uadd.with.overflow.