llvm.org GIT mirror llvm / 5a62d0a
remove a couple more unsafe xforms in the face of overflow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45613 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 0 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
48644864 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
48654865 if (isMinValuePlusOne(CI,true)) // A A == MIN
48664866 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, SubOne(CI));
4867
4868 // (icmp slt (sub A B) 1) -> (icmp sle A B)
4869 if (CI->isOne() && match(Op0, m_Sub(m_Value(A), m_Value(B))))
4870 return new ICmpInst(ICmpInst::ICMP_SLE, A, B);
48714867 break;
48724868
48734869 case ICmpInst::ICMP_UGT:
48914887 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
48924888 if (isMaxValueMinusOne(CI, true)) // A >s MAX-1 -> A == MAX
48934889 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, AddOne(CI));
4894
4895 // (icmp sgt (sub A B) -1) -> (icmp sge A B)
4896 if (CI->getValue().getSExtValue() == -1 &&
4897 match(Op0, m_Sub(m_Value(A), m_Value(B))))
4898 return new ICmpInst(ICmpInst::ICMP_SGE, A, B);
48994890 break;
49004891
49014892 case ICmpInst::ICMP_ULE:
+0
-25
test/Transforms/InstCombine/2007-12-19-IcmpSub.ll less more
None ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {sub}
1
2 define i32 @foo(i32 %a) {
3 entry:
4 %tmp2 = sub i32 99, %a ; [#uses=1]
5 %tmp3 = icmp sgt i32 %tmp2, -1 ; [#uses=1]
6 %retval = select i1 %tmp3, i32 %a, i32 0 ; [#uses=1]
7 ret i32 %retval
8 }
9
10 define i32 @bar(i32 %a) {
11 entry:
12 %tmp2 = sub i32 99, %a ; [#uses=1]
13 %tmp3 = icmp sge i32 %tmp2, 0; [#uses=1]
14 %retval = select i1 %tmp3, i32 %a, i32 0 ; [#uses=1]
15 ret i32 %retval
16 }
17
18 define i32 @baz(i32 %a) {
19 entry:
20 %tmp2 = sub i32 99, %a ; [#uses=1]
21 %tmp3 = icmp slt i32 %tmp2, 1 ; [#uses=1]
22 %retval = select i1 %tmp3, i32 %a, i32 0 ; [#uses=1]
23 ret i32 %retval
24 }