Eliminate more redundant llvm-as calls.
[oota-llvm.git] / test / Transforms / InstCombine / sub.ll
index 9ee8b068450ad714c5d44fea9bc10717774d295c..bd7a700e22ee6c5873a5f3ec5ff9514d2e9d3ceb 100644 (file)
@@ -1,7 +1,7 @@
 ; This test makes sure that these instructions are properly eliminated.
 ;
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
-; RUN:   grep -v {sub i32 %Cok, %Bok} | not grep sub
+; RUN: opt < %s -instcombine -S | \
+; RUN:   grep -v {sub i32 %Cok, %Bok} | grep -v {sub i32 0, %Aok} | not grep sub
 
 define i32 @test1(i32 %A) {
        %B = sub i32 %A, %A             ; <i32> [#uses=1]
@@ -104,8 +104,10 @@ define i32 @test16(i32 %A) {
        ret i32 %Y
 }
 
-define i32 @test17(i32 %A) {
-       %B = sub i32 0, %A              ; <i32> [#uses=1]
+; Can't fold subtract here because negation it might oveflow.
+; PR3142
+define i32 @test17(i32 %Aok) {
+       %B = sub i32 0, %Aok            ; <i32> [#uses=1]
        %C = sdiv i32 %B, 1234          ; <i32> [#uses=1]
        ret i32 %C
 }
@@ -134,3 +136,13 @@ define i1 @test21(i32 %g, i32 %h) {
        %tmp.4 = icmp ne i32 %tmp.2, %g         ; <i1> [#uses=1]
        ret i1 %tmp.4
 }
+
+; PR2298
+define i8 @test22(i32 %a, i32 %b) zeroext nounwind  {
+       %tmp2 = sub i32 0, %a           ; <i32> [#uses=1]
+       %tmp4 = sub i32 0, %b           ; <i32> [#uses=1]
+       %tmp5 = icmp eq i32 %tmp2, %tmp4                ; <i1> [#uses=1]
+       %retval89 = zext i1 %tmp5 to i8         ; <i8> [#uses=1]
+       ret i8 %retval89
+}
+