More working CellSPU test cases:
[oota-llvm.git] / test / CodeGen / CellSPU / select_bits.ll
1 ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
2 ; RUN: grep selb   %t1.s | count 160
3 ; RUN: grep and    %t1.s | count 2
4 ; RUN: grep xsbh   %t1.s | count 1
5 ; RUN: grep xshw   %t1.s | count 2
6
7 define <16 x i8> @selb_v16i8_1(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
8         %A = xor <16 x i8> %arg3, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
9                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
10                                     i8 -1, i8 -1, i8 -1, i8 -1 >
11         %B = and <16 x i8> %A, %arg1            ; <<16 x i8>> [#uses=1]
12         %C = and <16 x i8> %arg2, %arg3         ; <<16 x i8>> [#uses=1]
13         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
14         ret <16 x i8> %D
15 }
16
17 define <16 x i8> @selb_v16i8_11(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
18         %A = xor <16 x i8> %arg3, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
19                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
20                                     i8 -1, i8 -1, i8 -1, i8 -1 >
21         %B = and <16 x i8> %arg1, %A            ; <<16 x i8>> [#uses=1]
22         %C = and <16 x i8> %arg3, %arg2         ; <<16 x i8>> [#uses=1]
23         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
24         ret <16 x i8> %D
25 }
26
27 define <16 x i8> @selb_v16i8_12(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
28         %A = xor <16 x i8> %arg3, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
29                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
30                                     i8 -1, i8 -1, i8 -1, i8 -1 >
31         %B = and <16 x i8> %arg1, %A            ; <<16 x i8>> [#uses=1]
32         %C = and <16 x i8> %arg2, %arg3         ; <<16 x i8>> [#uses=1]
33         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
34         ret <16 x i8> %D
35 }
36
37 define <16 x i8> @selb_v16i8_13(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
38         %A = xor <16 x i8> %arg3, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
39                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
40                                     i8 -1, i8 -1, i8 -1, i8 -1 >
41         %B = and <16 x i8> %A, %arg1            ; <<16 x i8>> [#uses=1]
42         %C = and <16 x i8> %arg2, %arg3         ; <<16 x i8>> [#uses=1]
43         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
44         ret <16 x i8> %D
45 }
46
47 define <16 x i8> @selb_v16i8_2(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
48         %A = xor <16 x i8> %arg1, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
49                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
50                                     i8 -1, i8 -1, i8 -1, i8 -1 >
51         %B = and <16 x i8> %A, %arg2            ; <<16 x i8>> [#uses=1]
52         %C = and <16 x i8> %arg3, %arg1         ; <<16 x i8>> [#uses=1]
53         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
54         ret <16 x i8> %D
55 }
56
57 define <16 x i8> @selb_v16i8_21(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
58         %A = xor <16 x i8> %arg1, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
59                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
60                                     i8 -1, i8 -1, i8 -1, i8 -1 >
61         %B = and <16 x i8> %arg2, %A            ; <<16 x i8>> [#uses=1]
62         %C = and <16 x i8> %arg3, %arg1         ; <<16 x i8>> [#uses=1]
63         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
64         ret <16 x i8> %D
65 }
66
67 define <16 x i8> @selb_v16i8_3(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
68         %A = xor <16 x i8> %arg2, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
69                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
70                                     i8 -1, i8 -1, i8 -1, i8 -1 >
71         %B = and <16 x i8> %A, %arg1            ; <<16 x i8>> [#uses=1]
72         %C = and <16 x i8> %arg3, %arg2         ; <<16 x i8>> [#uses=1]
73         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
74         ret <16 x i8> %D
75 }
76
77 define <16 x i8> @selb_v16i8_4(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
78         %C = and <16 x i8> %arg3, %arg2         ; <<16 x i8>> [#uses=1]
79         %A = xor <16 x i8> %arg2, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
80                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
81                                     i8 -1, i8 -1, i8 -1, i8 -1 >
82         %B = and <16 x i8> %A, %arg1            ; <<16 x i8>> [#uses=1]
83         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
84         ret <16 x i8> %D
85 }
86
87 define <16 x i8> @selb_v16i8_41(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
88         %C = and <16 x i8> %arg2, %arg3         ; <<16 x i8>> [#uses=1]
89         %A = xor <16 x i8> %arg2, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
90                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
91                                     i8 -1, i8 -1, i8 -1, i8 -1 >
92         %B = and <16 x i8> %arg1, %A            ; <<16 x i8>> [#uses=1]
93         %D = or <16 x i8> %C, %B                ; <<16 x i8>> [#uses=1]
94         ret <16 x i8> %D
95 }
96
97 define <16 x i8> @selb_v16i8_42(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
98         %C = and <16 x i8> %arg2, %arg3         ; <<16 x i8>> [#uses=1]
99         %A = xor <16 x i8> %arg2, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
100                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
101                                     i8 -1, i8 -1, i8 -1, i8 -1 >
102         %B = and <16 x i8> %A, %arg1            ; <<16 x i8>> [#uses=1]
103         %D = or <16 x i8> %C, %B                ; <<16 x i8>> [#uses=1]
104         ret <16 x i8> %D
105 }
106
107 define <16 x i8> @selb_v16i8_5(<16 x i8> %arg1, <16 x i8> %arg2, <16 x i8> %arg3) {
108         %C = and <16 x i8> %arg2, %arg1         ; <<16 x i8>> [#uses=1]
109         %A = xor <16 x i8> %arg1, < i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
110                                     i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
111                                     i8 -1, i8 -1, i8 -1, i8 -1 >
112         %B = and <16 x i8> %A, %arg3            ; <<16 x i8>> [#uses=1]
113         %D = or <16 x i8> %B, %C                ; <<16 x i8>> [#uses=1]
114         ret <16 x i8> %D
115 }
116
117 define <8 x i16> @selb_v8i16_1(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
118         %A = xor <8 x i16> %arg3, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
119                                     i16 -1, i16 -1 >
120         %B = and <8 x i16> %A, %arg1            ; <<8 x i16>> [#uses=1]
121         %C = and <8 x i16> %arg2, %arg3         ; <<8 x i16>> [#uses=1]
122         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
123         ret <8 x i16> %D
124 }
125
126 define <8 x i16> @selb_v8i16_11(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
127         %A = xor <8 x i16> %arg3, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
128                                     i16 -1, i16 -1 >
129         %B = and <8 x i16> %arg1, %A            ; <<8 x i16>> [#uses=1]
130         %C = and <8 x i16> %arg3, %arg2         ; <<8 x i16>> [#uses=1]
131         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
132         ret <8 x i16> %D
133 }
134
135 define <8 x i16> @selb_v8i16_12(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
136         %A = xor <8 x i16> %arg3, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
137                                     i16 -1, i16 -1 >
138         %B = and <8 x i16> %arg1, %A            ; <<8 x i16>> [#uses=1]
139         %C = and <8 x i16> %arg2, %arg3         ; <<8 x i16>> [#uses=1]
140         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
141         ret <8 x i16> %D
142 }
143
144 define <8 x i16> @selb_v8i16_13(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
145         %A = xor <8 x i16> %arg3, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
146                                     i16 -1, i16 -1 >
147         %B = and <8 x i16> %A, %arg1            ; <<8 x i16>> [#uses=1]
148         %C = and <8 x i16> %arg2, %arg3         ; <<8 x i16>> [#uses=1]
149         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
150         ret <8 x i16> %D
151 }
152
153 define <8 x i16> @selb_v8i16_2(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
154         %A = xor <8 x i16> %arg1, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
155                                     i16 -1, i16 -1 >
156         %B = and <8 x i16> %A, %arg2            ; <<8 x i16>> [#uses=1]
157         %C = and <8 x i16> %arg3, %arg1         ; <<8 x i16>> [#uses=1]
158         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
159         ret <8 x i16> %D
160 }
161
162 define <8 x i16> @selb_v8i16_21(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
163         %A = xor <8 x i16> %arg1, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
164                                     i16 -1, i16 -1 >
165         %B = and <8 x i16> %arg2, %A            ; <<8 x i16>> [#uses=1]
166         %C = and <8 x i16> %arg3, %arg1         ; <<8 x i16>> [#uses=1]
167         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
168         ret <8 x i16> %D
169 }
170
171 define <8 x i16> @selb_v8i16_3(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
172         %A = xor <8 x i16> %arg2, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
173                                     i16 -1, i16 -1 >
174         %B = and <8 x i16> %A, %arg1            ; <<8 x i16>> [#uses=1]
175         %C = and <8 x i16> %arg3, %arg2         ; <<8 x i16>> [#uses=1]
176         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
177         ret <8 x i16> %D
178 }
179
180 define <8 x i16> @selb_v8i16_4(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
181         %C = and <8 x i16> %arg3, %arg2         ; <<8 x i16>> [#uses=1]
182         %A = xor <8 x i16> %arg2, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
183                                     i16 -1, i16 -1 >
184         %B = and <8 x i16> %A, %arg1            ; <<8 x i16>> [#uses=1]
185         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
186         ret <8 x i16> %D
187 }
188
189 define <8 x i16> @selb_v8i16_41(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
190         %C = and <8 x i16> %arg2, %arg3         ; <<8 x i16>> [#uses=1]
191         %A = xor <8 x i16> %arg2, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
192                                     i16 -1, i16 -1 >
193         %B = and <8 x i16> %arg1, %A            ; <<8 x i16>> [#uses=1]
194         %D = or <8 x i16> %C, %B                ; <<8 x i16>> [#uses=1]
195         ret <8 x i16> %D
196 }
197
198 define <8 x i16> @selb_v8i16_42(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
199         %C = and <8 x i16> %arg2, %arg3         ; <<8 x i16>> [#uses=1]
200         %A = xor <8 x i16> %arg2, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
201                                     i16 -1, i16 -1 >
202         %B = and <8 x i16> %A, %arg1            ; <<8 x i16>> [#uses=1]
203         %D = or <8 x i16> %C, %B                ; <<8 x i16>> [#uses=1]
204         ret <8 x i16> %D
205 }
206
207 define <8 x i16> @selb_v8i16_5(<8 x i16> %arg1, <8 x i16> %arg2, <8 x i16> %arg3) {
208         %C = and <8 x i16> %arg2, %arg1         ; <<8 x i16>> [#uses=1]
209         %A = xor <8 x i16> %arg1, < i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1,
210                                     i16 -1, i16 -1 >
211         %B = and <8 x i16> %A, %arg3            ; <<8 x i16>> [#uses=1]
212         %D = or <8 x i16> %B, %C                ; <<8 x i16>> [#uses=1]
213         ret <8 x i16> %D
214 }
215
216 define <4 x i32> @selb_v4i32_1(<4 x i32> %arg1, <4 x i32> %arg2, <4 x i32> %arg3) {
217         %tmpnot = xor <4 x i32> %arg3, < i32 -1, i32 -1, i32 -1, i32 -1 >               ; <<4 x i32>> [#uses=1]
218         %tmp2 = and <4 x i32> %tmpnot, %arg1            ; <<4 x i32>> [#uses=1]
219         %tmp5 = and <4 x i32> %arg2, %arg3              ; <<4 x i32>> [#uses=1]
220         %tmp6 = or <4 x i32> %tmp2, %tmp5               ; <<4 x i32>> [#uses=1]
221         ret <4 x i32> %tmp6
222 }
223
224 define <4 x i32> @selb_v4i32_2(<4 x i32> %arg1, <4 x i32> %arg2, <4 x i32> %arg3) {
225         %tmpnot = xor <4 x i32> %arg3, < i32 -1, i32 -1, i32 -1, i32 -1 >               ; <<4 x i32>> [#uses=1]
226         %tmp2 = and <4 x i32> %tmpnot, %arg1            ; <<4 x i32>> [#uses=1]
227         %tmp5 = and <4 x i32> %arg2, %arg3              ; <<4 x i32>> [#uses=1]
228         %tmp6 = or <4 x i32> %tmp2, %tmp5               ; <<4 x i32>> [#uses=1]
229         ret <4 x i32> %tmp6
230 }
231
232 define <4 x i32> @selb_v4i32_3(<4 x i32> %arg1, <4 x i32> %arg2, <4 x i32> %arg3) {
233         %tmpnot = xor <4 x i32> %arg3, < i32 -1, i32 -1, i32 -1, i32 -1 >               ; <<4 x i32>> [#uses=1]
234         %tmp2 = and <4 x i32> %tmpnot, %arg1            ; <<4 x i32>> [#uses=1]
235         %tmp5 = and <4 x i32> %arg3, %arg2              ; <<4 x i32>> [#uses=1]
236         %tmp6 = or <4 x i32> %tmp2, %tmp5               ; <<4 x i32>> [#uses=1]
237         ret <4 x i32> %tmp6
238 }
239
240 define <4 x i32> @selb_v4i32_4(<4 x i32> %arg1, <4 x i32> %arg2, <4 x i32> %arg3) {
241         %tmp2 = and <4 x i32> %arg3, %arg2              ; <<4 x i32>> [#uses=1]
242         %tmp3not = xor <4 x i32> %arg3, < i32 -1, i32 -1, i32 -1, i32 -1 >              ; <<4 x i32>> [#uses=1]
243         %tmp5 = and <4 x i32> %tmp3not, %arg1           ; <<4 x i32>> [#uses=1]
244         %tmp6 = or <4 x i32> %tmp2, %tmp5               ; <<4 x i32>> [#uses=1]
245         ret <4 x i32> %tmp6
246 }
247
248 define <4 x i32> @selb_v4i32_5(<4 x i32> %arg1, <4 x i32> %arg2, <4 x i32> %arg3) {
249         %tmp2 = and <4 x i32> %arg3, %arg2              ; <<4 x i32>> [#uses=1]
250         %tmp3not = xor <4 x i32> %arg3, < i32 -1, i32 -1, i32 -1, i32 -1 >              ; <<4 x i32>> [#uses=1]
251         %tmp5 = and <4 x i32> %tmp3not, %arg1           ; <<4 x i32>> [#uses=1]
252         %tmp6 = or <4 x i32> %tmp2, %tmp5               ; <<4 x i32>> [#uses=1]
253         ret <4 x i32> %tmp6
254 }
255
256 define i32 @selb_i32(i32 %arg1, i32 %arg2, i32 %arg3) {
257         %tmp1not = xor i32 %arg3, -1            ; <i32> [#uses=1]
258         %tmp3 = and i32 %tmp1not, %arg1         ; <i32> [#uses=1]
259         %tmp6 = and i32 %arg3, %arg2            ; <i32> [#uses=1]
260         %tmp7 = or i32 %tmp3, %tmp6             ; <i32> [#uses=1]
261         ret i32 %tmp7
262 }
263
264 define i16 @selb_i16(i16 signext  %arg1, i16 signext  %arg2, i16 signext  %arg3) signext  {
265         %tmp3 = and i16 %arg3, %arg1            ; <i16> [#uses=1]
266         %tmp4not = xor i16 %arg3, -1            ; <i16> [#uses=1]
267         %tmp6 = and i16 %tmp4not, %arg2         ; <i16> [#uses=1]
268         %retval1011 = or i16 %tmp3, %tmp6               ; <i16> [#uses=1]
269         ret i16 %retval1011
270 }
271
272 define i16 @selb_i16u(i16 zeroext  %arg1, i16 zeroext  %arg2, i16 zeroext  %arg3) zeroext  {
273         %tmp3 = and i16 %arg3, %arg1            ; <i16> [#uses=1]
274         %tmp4not = xor i16 %arg3, -1            ; <i16> [#uses=1]
275         %tmp6 = and i16 %tmp4not, %arg2         ; <i16> [#uses=1]
276         %retval1011 = or i16 %tmp3, %tmp6               ; <i16> [#uses=1]
277         ret i16 %retval1011
278 }
279
280 define i8 @selb_i8u(i8 zeroext  %arg1, i8 zeroext  %arg2, i8 zeroext  %arg3) zeroext  {
281         %tmp3 = and i8 %arg3, %arg1             ; <i8> [#uses=1]
282         %tmp4not = xor i8 %arg3, -1             ; <i8> [#uses=1]
283         %tmp6 = and i8 %tmp4not, %arg2          ; <i8> [#uses=1]
284         %retval1011 = or i8 %tmp3, %tmp6                ; <i8> [#uses=1]
285         ret i8 %retval1011
286 }
287
288 define i8 @selb_i8(i8 signext  %arg1, i8 signext  %arg2, i8 signext  %arg3) signext  {
289         %tmp3 = and i8 %arg3, %arg1             ; <i8> [#uses=1]
290         %tmp4not = xor i8 %arg3, -1             ; <i8> [#uses=1]
291         %tmp6 = and i8 %tmp4not, %arg2          ; <i8> [#uses=1]
292         %retval1011 = or i8 %tmp3, %tmp6                ; <i8> [#uses=1]
293         ret i8 %retval1011
294 }