; This test makes sure that add instructions are properly eliminated.
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
+; RUN: opt < %s -instcombine -S | \
; RUN: grep -v OK | not grep add
define i32 @test1(i32 %A) {
ret i32 %C
}
-; (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
+; (A & C1)+(B & C2) -> (A & C1)|(B & C2) if C1&C2 == 0
define i32 @test8(i32 %A, i32 %B) {
%A1 = and i32 %A, 7 ; <i32> [#uses=1]
%B1 = and i32 %B, 128 ; <i32> [#uses=1]
%q = and i32 %z, 1 ; always zero
ret i32 %q
}
+
+define i1 @test37(i32 %a, i32 %b) nounwind readnone {
+ %add = add i32 %a, %b
+ %cmp = icmp eq i32 %add, %a
+ ret i1 %cmp
+}
+
+define i1 @test38(i32 %a, i32 %b) nounwind readnone {
+ %add = add i32 %a, %b
+ %cmp = icmp eq i32 %add, %b
+ ret i1 %cmp
+}
+
+define i1 @test39(i32 %a, i32 %b) nounwind readnone {
+ %add = add i32 %b, %a
+ %cmp = icmp eq i32 %add, %a
+ ret i1 %cmp
+}
+
+define i1 @test40(i32 %a, i32 %b) nounwind readnone {
+ %add = add i32 %b, %a
+ %cmp = icmp eq i32 %add, %b
+ ret i1 %cmp
+}