Author: lattner
Date: Fri Jan  4 19:18:20 2008
New Revision: 45612

URL: http://llvm.org/viewvc/llvm-project?rev=45612&view=rev
Log:
remove the (x-y) < 0 comparison xform, it miscompiles 
things that are not equality comparisons, for example:
   (2147479553+4096)-2147479553 < 0    !=   (2147479553+4096) < 2147479553

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=45612&r1=45611&r2=45612&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan  4 
19:18:20 2008
@@ -4835,17 +4835,11 @@
   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()) {


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to