diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-05 01:18:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-05 01:18:20 +0000 |
commit | db026d703b1ec7ee604401e9e4e98a7e75deb4a7 (patch) | |
tree | 408a38b2c0394f09c5907a58705b286f268cd80c /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | e84b32e506536b3e8ef9bc789cabe4193cbece67 (diff) | |
download | bcm5719-llvm-db026d703b1ec7ee604401e9e4e98a7e75deb4a7.tar.gz bcm5719-llvm-db026d703b1ec7ee604401e9e4e98a7e75deb4a7.zip |
remove the (x-y) < 0 comparison xform, it miscompiles
things that are not equality comparisons, for example:
(2147479553+4096)-2147479553 < 0 != (2147479553+4096) < 2147479553
llvm-svn: 45612
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 489f0de5efe..83cacbab717 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4835,17 +4835,11 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) { Value *A, *B; - // (icmp cond (sub A B) 0) -> ... - if (CI->isNullValue() && match(Op0, m_Sub(m_Value(A), m_Value(B)))) { - // (icmp cond A B) if cond is signed or equality - if (CmpInst::isSigned(I.getPredicate()) || I.isEquality()) - return new ICmpInst(I.getPredicate(), A, B); - // (icmp ne A B) if cond is ugt - else if (I.getPredicate() == ICmpInst::ICMP_UGT) - return new ICmpInst(ICmpInst::ICMP_NE, A, B); - // (icmp eq A B) if cond is ule - else if (I.getPredicate() == ICmpInst::ICMP_ULE) - return new ICmpInst(ICmpInst::ICMP_EQ, A, B); + // (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B) + if (I.isEquality() && CI->isNullValue() && + match(Op0, m_Sub(m_Value(A), m_Value(B)))) { + // (icmp cond A B) if cond is equality + return new ICmpInst(I.getPredicate(), A, B); } switch (I.getPredicate()) { |