Use "opt < %s" instead of "opt %s" so that opt doesn't print the test
[oota-llvm.git] / test / Transforms / Reassociate / inverses.ll
1 ; RUN: opt < %s -reassociate -dce -S | \
2 ; RUN:   not grep {\\(and\\|sub\\)}
3
4 define i32 @test1(i32 %a, i32 %b) {
5         %tmp.2 = and i32 %b, %a         ; <i32> [#uses=1]
6         %tmp.4 = xor i32 %a, -1         ; <i32> [#uses=1]
7         ; (A&B)&~A == 0
8         %tmp.5 = and i32 %tmp.2, %tmp.4         ; <i32> [#uses=1]
9         ret i32 %tmp.5
10 }
11
12 define i32 @test2(i32 %a, i32 %b) {
13         %tmp.1 = and i32 %a, 1234               ; <i32> [#uses=1]
14         %tmp.2 = and i32 %b, %tmp.1             ; <i32> [#uses=1]
15         %tmp.4 = xor i32 %a, -1         ; <i32> [#uses=1]
16         ; A&~A == 0
17         %tmp.5 = and i32 %tmp.2, %tmp.4         ; <i32> [#uses=1]
18         ret i32 %tmp.5
19 }
20
21 define i32 @test3(i32 %b, i32 %a) {
22         %tmp.1 = add i32 %a, 1234               ; <i32> [#uses=1]
23         %tmp.2 = add i32 %b, %tmp.1             ; <i32> [#uses=1]
24         %tmp.4 = sub i32 0, %a          ; <i32> [#uses=1]
25         ; (b+(a+1234))+-a -> b+1234
26         %tmp.5 = add i32 %tmp.2, %tmp.4         ; <i32> [#uses=1]
27         ret i32 %tmp.5
28 }