aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-05 01:18:20 +0000
committerChris Lattner <sabre@nondot.org>2008-01-05 01:18:20 +0000
commitbe6c54a9ef5f556770ec07d429667f16b2ca6af4 (patch)
tree41583c62138e241d3fc3dead44ad3514182d6ec8 /lib
parent91eb6e6762367514cb1b3e9bb8da626417592398 (diff)
downloadexternal_llvm-be6c54a9ef5f556770ec07d429667f16b2ca6af4.zip
external_llvm-be6c54a9ef5f556770ec07d429667f16b2ca6af4.tar.gz
external_llvm-be6c54a9ef5f556770ec07d429667f16b2ca6af4.tar.bz2
remove the (x-y) < 0 comparison xform, it miscompiles
things that are not equality comparisons, for example: (2147479553+4096)-2147479553 < 0 != (2147479553+4096) < 2147479553 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 489f0de..83cacba 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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()) {