remove a couple more unsafe xforms in the face of overflow.
authorChris Lattner <sabre@nondot.org>
Sat, 5 Jan 2008 01:22:42 +0000 (01:22 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 5 Jan 2008 01:22:42 +0000 (01:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45613 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp
test/Transforms/InstCombine/2007-12-19-IcmpSub.ll [deleted file]

index 83cacbab71742f043960342b3b4505a957c7bd3e..1e12c79e68801c4d6b63c24ffd7b26388a612edb 100644 (file)
@@ -4865,10 +4865,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
         return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
       if (isMinValuePlusOne(CI,true))              // A <s MIN+1 -> A == MIN
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, SubOne(CI));
-      
-      // (icmp slt (sub A B) 1) -> (icmp sle A B)
-      if (CI->isOne() && match(Op0, m_Sub(m_Value(A), m_Value(B))))
-        return new ICmpInst(ICmpInst::ICMP_SLE, A, B);
       break;
 
     case ICmpInst::ICMP_UGT:
@@ -4892,11 +4888,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
         return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
       if (isMaxValueMinusOne(CI, true))           // A >s MAX-1 -> A == MAX
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, AddOne(CI));
-      
-      // (icmp sgt (sub A B) -1) -> (icmp sge A B)
-      if (CI->getValue().getSExtValue() == -1 && 
-          match(Op0, m_Sub(m_Value(A), m_Value(B))))
-        return new ICmpInst(ICmpInst::ICMP_SGE, A, B);
       break;
 
     case ICmpInst::ICMP_ULE:
diff --git a/test/Transforms/InstCombine/2007-12-19-IcmpSub.ll b/test/Transforms/InstCombine/2007-12-19-IcmpSub.ll
deleted file mode 100644 (file)
index ecb5e6e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {sub}
-
-define i32 @foo(i32 %a) {
-entry:
-       %tmp2 = sub i32 99, %a          ; <i32> [#uses=1]
-       %tmp3 = icmp sgt i32 %tmp2, -1          ; <i1> [#uses=1]
-       %retval = select i1 %tmp3, i32 %a, i32 0                ; <i32> [#uses=1]
-       ret i32 %retval
-}
-
-define i32 @bar(i32 %a) {
-entry:
-       %tmp2 = sub i32 99, %a          ; <i32> [#uses=1]
-       %tmp3 = icmp sge i32 %tmp2, 0; <i1> [#uses=1]
-       %retval = select i1 %tmp3, i32 %a, i32 0                ; <i32> [#uses=1]
-       ret i32 %retval
-}
-
-define i32 @baz(i32 %a) {
-entry:
-       %tmp2 = sub i32 99, %a          ; <i32> [#uses=1]
-       %tmp3 = icmp slt i32 %tmp2, 1           ; <i1> [#uses=1]
-       %retval = select i1 %tmp3, i32 %a, i32 0                ; <i32> [#uses=1]
-       ret i32 %retval
-}
\ No newline at end of file