Convert scripts from using explicit control flow to use the new grep-not script
[oota-llvm.git] / test / Transforms / InstCombine / add.ll
1 ; This test makes sure that add instructions are properly eliminated.
2 ;
3 ; This also tests that a subtract with a constant is properly converted
4 ; to a add w/negative constant
5
6 ; RUN: as < %s | opt -instcombine -die | dis | grep-not add
7
8 implementation
9
10 int %test1(int %A) {
11         %B = add int %A, 0
12         ret int %B
13 }
14
15 int %test2(int %A) {
16         %B = add int %A, 5
17         %C = add int %B, -5
18         ret int %C
19 }
20
21 int %test3(int %A) {
22         %B = add int %A, 5
23         %C = sub int %B, 5   ;; This should get converted to an add
24         ret int %C
25 }
26
27 int %test4(int %A, int %B) {
28         %C = sub int 0, %A
29         %D = add int %B, %C      ; D = B + -A = B - A
30         ret int %D
31 }
32
33 int %test5(int %A, int %B) {
34         %C = sub int 0, %A
35         %D = add int %C, %B      ; D = -A + B = B - A
36         ret int %D
37 }
38
39 int %test6(int %A) {
40         %B = mul int 7, %A
41         %C = add int %B, %A      ; C = 7*A+A == 8*A == A << 3
42         ret int %C
43 }
44
45 int %test7(int %A) {
46         %B = mul int 7, %A
47         %C = add int %A, %B      ; C = A+7*A == 8*A == A << 3
48         ret int %C
49 }
50
51 int %test8(int %A, int %B) {     ; (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
52         %A1 = and int %A, 7
53         %B1 = and int %B, 128
54         %C = add int %A1, %B1
55         ret int %C
56 }
57