For PR950:
[oota-llvm.git] / test / Transforms / InstCombine / set.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output &&
4 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep icmp
5
6 %X = uninitialized global int
7
8 bool %test1(int %A) {
9         %B = seteq int %A, %A
10         %C = seteq int* %X, null   ; Never true
11         %D = and bool %B, %C
12         ret bool %D
13 }
14
15 bool %test2(int %A) {
16         %B = setne int %A, %A
17         %C = setne int* %X, null   ; Never false
18         %D = or bool %B, %C
19         ret bool %D
20 }
21
22 bool %test3(int %A) {
23         %B = setlt int %A, %A
24         ret bool %B
25 }
26
27 bool %test4(int %A) {
28         %B = setgt int %A, %A
29         ret bool %B
30 }
31
32 bool %test5(int %A) {
33         %B = setle int %A, %A
34         ret bool %B
35 }
36
37 bool %test6(int %A) {
38         %B = setge int %A, %A
39         ret bool %B
40 }
41
42 bool %test7(uint %A) {
43         %B = setge uint %A, 0  ; true
44         ret bool %B
45 }
46
47 bool %test8(uint %A) {
48         %B = setlt uint %A, 0  ; false
49         ret bool %B
50 }
51
52 ;; test operations on boolean values these should all be eliminated$a
53 bool %test9(bool %A) {
54         %B = setlt bool %A, false ; false
55         ret bool %B
56 }
57 bool %test10(bool %A) {
58         %B = setgt bool %A, true  ; false
59         ret bool %B
60 }
61 bool %test11(bool %A) {
62         %B = setle bool %A, true ; true
63         ret bool %B
64 }
65 bool %test12(bool %A) {
66         %B = setge bool %A, false  ; true
67         ret bool %B
68 }
69 bool %test13(bool %A, bool %B) {
70         %C = setge bool %A, %B       ; A | ~B
71         ret bool %C
72 }
73 bool %test14(bool %A, bool %B) {
74         %C = seteq bool %A, %B  ; ~(A ^ B)
75         ret bool %C
76 }
77
78 bool %test16(uint %A) {
79         %B = and uint %A, 5
80         %C = seteq uint %B, 8    ; Is never true
81         ret bool %C
82 }
83
84 bool %test17(ubyte %A) {
85         %B = or ubyte %A, 1
86         %C = seteq ubyte %B, 2   ; Always false
87         ret bool %C
88 }
89
90 bool %test18(bool %C, int %a) {
91 entry:
92         br bool %C, label %endif, label %else
93
94 else:
95         br label %endif
96
97 endif:
98         %b.0 = phi int [ 0, %entry ], [ 1, %else ]
99         %tmp.4 = setlt int %b.0, 123
100         ret bool %tmp.4
101 }
102
103 bool %test19(bool %A, bool %B) {
104         %a = cast bool %A to int
105         %b = cast bool %B to int
106         %C = seteq int %a, %b
107         ret bool %C
108 }
109
110 uint %test20(uint %A) {
111         %B = and uint %A, 1
112         %C = setne uint %B, 0
113         %D = cast bool %C to uint
114         ret uint %D
115 }
116
117 int %test21(int %a) {
118         %tmp.6 = and int %a, 4
119         %not.tmp.7 = setne int %tmp.6, 0
120         %retval = cast bool %not.tmp.7 to int
121         ret int %retval
122 }
123
124 bool %test22(uint %A, int %X) {
125         %B = and uint %A, 100663295
126         %C = setlt uint %B, 268435456
127         %Y = and int %X, 7
128         %Z = setgt int %Y, -1
129         %R = or bool %C, %Z
130         ret bool %R
131 }
132
133 int %test23(int %a) {
134         %tmp.1 = and int %a, 1
135         %tmp.2 = seteq int %tmp.1, 0
136         %tmp.3 = cast bool %tmp.2 to int  ;; xor tmp1, 1
137         ret int %tmp.3
138 }
139
140 int %test24(uint %a) {
141         %tmp1 = and uint %a, 4
142         %tmp.1 = shr uint %tmp1, ubyte 2
143         %tmp.2 = seteq uint %tmp.1, 0
144         %tmp.3 = cast bool %tmp.2 to int  ;; xor tmp1, 1
145         ret int %tmp.3
146 }
147