New testcase
[oota-llvm.git] / test / Transforms / InstCombine / or.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: if as < %s | opt -instcombine | dis | grep -v '%OROK = or' | grep or\ 
5 ; RUN: then exit 1
6 ; RUN: else exit 0
7 ; RUN: fi
8
9 implementation
10
11 int %test1(int %A) {
12         %B = or int %A, 0
13         ret int %B
14 }
15
16 int %test2(int %A) {
17         %B = or int %A, -1
18         ret int %B
19 }
20
21 ubyte %test2a(ubyte %A) {
22         %B = or ubyte %A, 255
23         ret ubyte %B
24 }
25
26 bool %test3(bool %A) {
27         %B = or bool %A, false
28         ret bool %B
29 }
30
31 bool %test4(bool %A) {
32         %B = or bool %A, true
33         ret bool %B
34 }
35
36 bool %test5(bool %A) {
37         %B = xor bool %A, false
38         ret bool %B
39 }
40
41 int %test6(int %A) {
42         %B = xor int %A, 0
43         ret int %B
44 }
45
46 bool %test7(bool %A) {
47         %B = xor bool %A, %A
48         ret bool %B
49 }
50
51 int %test8(int %A) {
52         %B = xor int %A, %A
53         ret int %B
54 }
55
56 bool %test9(bool %A) {
57         %B = or bool %A, %A
58         ret bool %B
59 }
60
61 int %test10(int %A) {
62         %B = or int %A, %A
63         ret int %B
64 }
65
66 int %test11(int %A) {    ; A ^ ~A == -1
67         %NotA = xor int -1, %A
68         %B = xor int %A, %NotA
69         ret int %B
70 }
71
72 int %test12(int %A) {    ; A | ~A == -1
73         %NotA = xor int -1, %A
74         %B = or int %A, %NotA
75         ret int %B
76 }
77
78 uint %test13(uint %A) { ; (A|B)^B == A & (~B)
79         %t1 = or uint %A, 123
80         %r  = xor uint %t1, 123
81         ret uint %r
82 }
83
84 ubyte %test14(ubyte %A) {
85         %B = or ubyte %A, 254
86         %C = or ubyte %B, 1
87         ret ubyte %C
88 }
89 ubyte %test15(ubyte %A) {
90         %B = xor ubyte %A, 17
91         %C = xor ubyte %B, 17
92         ret ubyte %C
93 }
94
95 int %test16(int %A, int %B) {     ; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
96         %A1 = and int %A, 7
97         %B1 = and int %B, 128
98         %OROK = xor int %A1, %B1
99         ret int %OROK
100 }
101
102 ubyte %test17(ubyte %A, ubyte %B) {  ; Test that (A|c1)|(B|c2) == (A|B)|(c1|c2)
103         %C = or ubyte %A, 1
104         %D = or ubyte %B, 254
105         %E = or ubyte %C, %D
106         ret ubyte %E
107 }