CellSPU:
[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 56
3
4 target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128"
5 target triple = "spu"
6
7 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
8 ; v2i64
9 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
10
11 ; (or (and rC, rB), (and (not rC), rA))
12 define <2 x i64> @selectbits_v2i64_01(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
13         %C = and <2 x i64> %rC, %rB
14         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
15         %B = and <2 x i64> %A, %rA
16         %D = or <2 x i64> %C, %B
17         ret <2 x i64> %D
18 }
19
20 ; (or (and rB, rC), (and (not rC), rA))
21 define <2 x i64> @selectbits_v2i64_02(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
22         %C = and <2 x i64> %rB, %rC
23         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
24         %B = and <2 x i64> %A, %rA
25         %D = or <2 x i64> %C, %B
26         ret <2 x i64> %D
27 }
28
29 ; (or (and (not rC), rA), (and rB, rC))
30 define <2 x i64> @selectbits_v2i64_03(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
31         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
32         %B = and <2 x i64> %A, %rA
33         %C = and <2 x i64> %rB, %rC
34         %D = or <2 x i64> %C, %B
35         ret <2 x i64> %D
36 }
37
38 ; (or (and (not rC), rA), (and rC, rB))
39 define <2 x i64> @selectbits_v2i64_04(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
40         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
41         %B = and <2 x i64> %A, %rA
42         %C = and <2 x i64> %rC, %rB
43         %D = or <2 x i64> %C, %B
44         ret <2 x i64> %D
45 }
46
47 ; (or (and rC, rB), (and rA, (not rC)))
48 define <2 x i64> @selectbits_v2i64_05(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
49         %C = and <2 x i64> %rC, %rB
50         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
51         %B = and <2 x i64> %rA, %A
52         %D = or <2 x i64> %C, %B
53         ret <2 x i64> %D
54 }
55
56 ; (or (and rB, rC), (and rA, (not rC)))
57 define <2 x i64> @selectbits_v2i64_06(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
58         %C = and <2 x i64> %rB, %rC
59         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
60         %B = and <2 x i64> %rA, %A
61         %D = or <2 x i64> %C, %B
62         ret <2 x i64> %D
63 }
64
65 ; (or (and rA, (not rC)), (and rB, rC))
66 define <2 x i64> @selectbits_v2i64_07(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
67         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
68         %B = and <2 x i64> %rA, %A
69         %C = and <2 x i64> %rB, %rC
70         %D = or <2 x i64> %C, %B
71         ret <2 x i64> %D
72 }
73
74 ; (or (and rA, (not rC)), (and rC, rB))
75 define <2 x i64> @selectbits_v2i64_08(<2 x i64> %rA, <2 x i64> %rB, <2 x i64> %rC) {
76         %A = xor <2 x i64> %rC, < i64 -1, i64 -1 >
77         %B = and <2 x i64> %rA, %A
78         %C = and <2 x i64> %rC, %rB
79         %D = or <2 x i64> %C, %B
80         ret <2 x i64> %D
81 }
82
83 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
84 ; v4i32
85 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
86
87 ; (or (and rC, rB), (and (not rC), rA))
88 define <4 x i32> @selectbits_v4i32_01(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
89         %C = and <4 x i32> %rC, %rB
90         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1 >
91         %B = and <4 x i32> %A, %rA
92         %D = or <4 x i32> %C, %B
93         ret <4 x i32> %D
94 }
95
96 ; (or (and rB, rC), (and (not rC), rA))
97 define <4 x i32> @selectbits_v4i32_02(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
98         %C = and <4 x i32> %rB, %rC
99         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1 >
100         %B = and <4 x i32> %A, %rA
101         %D = or <4 x i32> %C, %B
102         ret <4 x i32> %D
103 }
104
105 ; (or (and (not rC), rA), (and rB, rC))
106 define <4 x i32> @selectbits_v4i32_03(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
107         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1 >
108         %B = and <4 x i32> %A, %rA
109         %C = and <4 x i32> %rB, %rC
110         %D = or <4 x i32> %C, %B
111         ret <4 x i32> %D
112 }
113
114 ; (or (and (not rC), rA), (and rC, rB))
115 define <4 x i32> @selectbits_v4i32_04(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
116         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1>
117         %B = and <4 x i32> %A, %rA
118         %C = and <4 x i32> %rC, %rB
119         %D = or <4 x i32> %C, %B
120         ret <4 x i32> %D
121 }
122
123 ; (or (and rC, rB), (and rA, (not rC)))
124 define <4 x i32> @selectbits_v4i32_05(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
125         %C = and <4 x i32> %rC, %rB
126         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1>
127         %B = and <4 x i32> %rA, %A
128         %D = or <4 x i32> %C, %B
129         ret <4 x i32> %D
130 }
131
132 ; (or (and rB, rC), (and rA, (not rC)))
133 define <4 x i32> @selectbits_v4i32_06(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
134         %C = and <4 x i32> %rB, %rC
135         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1>
136         %B = and <4 x i32> %rA, %A
137         %D = or <4 x i32> %C, %B
138         ret <4 x i32> %D
139 }
140
141 ; (or (and rA, (not rC)), (and rB, rC))
142 define <4 x i32> @selectbits_v4i32_07(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
143         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1>
144         %B = and <4 x i32> %rA, %A
145         %C = and <4 x i32> %rB, %rC
146         %D = or <4 x i32> %C, %B
147         ret <4 x i32> %D
148 }
149
150 ; (or (and rA, (not rC)), (and rC, rB))
151 define <4 x i32> @selectbits_v4i32_08(<4 x i32> %rA, <4 x i32> %rB, <4 x i32> %rC) {
152         %A = xor <4 x i32> %rC, < i32 -1, i32 -1, i32 -1, i32 -1>
153         %B = and <4 x i32> %rA, %A
154         %C = and <4 x i32> %rC, %rB
155         %D = or <4 x i32> %C, %B
156         ret <4 x i32> %D
157 }
158
159 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
160 ; v8i16
161 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
162
163 ; (or (and rC, rB), (and (not rC), rA))
164 define <8 x i16> @selectbits_v8i16_01(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
165         %C = and <8 x i16> %rC, %rB
166         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
167                                   i16 -1, i16 -1, i16 -1, i16 -1 >
168         %B = and <8 x i16> %A, %rA
169         %D = or <8 x i16> %C, %B
170         ret <8 x i16> %D
171 }
172
173 ; (or (and rB, rC), (and (not rC), rA))
174 define <8 x i16> @selectbits_v8i16_02(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
175         %C = and <8 x i16> %rB, %rC
176         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
177                                   i16 -1, i16 -1, i16 -1, i16 -1 >
178         %B = and <8 x i16> %A, %rA
179         %D = or <8 x i16> %C, %B
180         ret <8 x i16> %D
181 }
182
183 ; (or (and (not rC), rA), (and rB, rC))
184 define <8 x i16> @selectbits_v8i16_03(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
185         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
186                                   i16 -1, i16 -1, i16 -1, i16 -1 >
187         %B = and <8 x i16> %A, %rA
188         %C = and <8 x i16> %rB, %rC
189         %D = or <8 x i16> %C, %B
190         ret <8 x i16> %D
191 }
192
193 ; (or (and (not rC), rA), (and rC, rB))
194 define <8 x i16> @selectbits_v8i16_04(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
195         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
196                                   i16 -1, i16 -1, i16 -1, i16 -1 >
197         %B = and <8 x i16> %A, %rA
198         %C = and <8 x i16> %rC, %rB
199         %D = or <8 x i16> %C, %B
200         ret <8 x i16> %D
201 }
202
203 ; (or (and rC, rB), (and rA, (not rC)))
204 define <8 x i16> @selectbits_v8i16_05(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
205         %C = and <8 x i16> %rC, %rB
206         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
207                                   i16 -1, i16 -1, i16 -1, i16 -1 >
208         %B = and <8 x i16> %rA, %A
209         %D = or <8 x i16> %C, %B
210         ret <8 x i16> %D
211 }
212
213 ; (or (and rB, rC), (and rA, (not rC)))
214 define <8 x i16> @selectbits_v8i16_06(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
215         %C = and <8 x i16> %rB, %rC
216         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
217                                   i16 -1, i16 -1, i16 -1, i16 -1 >
218         %B = and <8 x i16> %rA, %A
219         %D = or <8 x i16> %C, %B
220         ret <8 x i16> %D
221 }
222
223 ; (or (and rA, (not rC)), (and rB, rC))
224 define <8 x i16> @selectbits_v8i16_07(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
225         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
226                                   i16 -1, i16 -1, i16 -1, i16 -1 >
227         %B = and <8 x i16> %rA, %A
228         %C = and <8 x i16> %rB, %rC
229         %D = or <8 x i16> %C, %B
230         ret <8 x i16> %D
231 }
232
233 ; (or (and rA, (not rC)), (and rC, rB))
234 define <8 x i16> @selectbits_v8i16_08(<8 x i16> %rA, <8 x i16> %rB, <8 x i16> %rC) {
235         %A = xor <8 x i16> %rC, < i16 -1, i16 -1, i16 -1, i16 -1,
236                                   i16 -1, i16 -1, i16 -1, i16 -1 >
237         %B = and <8 x i16> %rA, %A
238         %C = and <8 x i16> %rC, %rB
239         %D = or <8 x i16> %C, %B
240         ret <8 x i16> %D
241 }
242
243 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
244 ; v16i8
245 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
246
247 ; (or (and rC, rB), (and (not rC), rA))
248 define <16 x i8> @selectbits_v16i8_01(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
249         %C = and <16 x i8> %rC, %rB
250         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
251                                   i8 -1, i8 -1, i8 -1, i8 -1,
252                                   i8 -1, i8 -1, i8 -1, i8 -1,
253                                   i8 -1, i8 -1, i8 -1, i8 -1 >
254         %B = and <16 x i8> %A, %rA
255         %D = or <16 x i8> %C, %B
256         ret <16 x i8> %D
257 }
258
259 ; (or (and rB, rC), (and (not rC), rA))
260 define <16 x i8> @selectbits_v16i8_02(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
261         %C = and <16 x i8> %rB, %rC
262         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
263                                   i8 -1, i8 -1, i8 -1, i8 -1,
264                                   i8 -1, i8 -1, i8 -1, i8 -1,
265                                   i8 -1, i8 -1, i8 -1, i8 -1 >
266         %B = and <16 x i8> %A, %rA
267         %D = or <16 x i8> %C, %B
268         ret <16 x i8> %D
269 }
270
271 ; (or (and (not rC), rA), (and rB, rC))
272 define <16 x i8> @selectbits_v16i8_03(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
273         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
274                                   i8 -1, i8 -1, i8 -1, i8 -1,
275                                   i8 -1, i8 -1, i8 -1, i8 -1,
276                                   i8 -1, i8 -1, i8 -1, i8 -1 >
277         %B = and <16 x i8> %A, %rA
278         %C = and <16 x i8> %rB, %rC
279         %D = or <16 x i8> %C, %B
280         ret <16 x i8> %D
281 }
282
283 ; (or (and (not rC), rA), (and rC, rB))
284 define <16 x i8> @selectbits_v16i8_04(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
285         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
286                                   i8 -1, i8 -1, i8 -1, i8 -1,
287                                   i8 -1, i8 -1, i8 -1, i8 -1,
288                                   i8 -1, i8 -1, i8 -1, i8 -1 >
289         %B = and <16 x i8> %A, %rA
290         %C = and <16 x i8> %rC, %rB
291         %D = or <16 x i8> %C, %B
292         ret <16 x i8> %D
293 }
294
295 ; (or (and rC, rB), (and rA, (not rC)))
296 define <16 x i8> @selectbits_v16i8_05(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
297         %C = and <16 x i8> %rC, %rB
298         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
299                                   i8 -1, i8 -1, i8 -1, i8 -1,
300                                   i8 -1, i8 -1, i8 -1, i8 -1,
301                                   i8 -1, i8 -1, i8 -1, i8 -1 >
302         %B = and <16 x i8> %rA, %A
303         %D = or <16 x i8> %C, %B
304         ret <16 x i8> %D
305 }
306
307 ; (or (and rB, rC), (and rA, (not rC)))
308 define <16 x i8> @selectbits_v16i8_06(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
309         %C = and <16 x i8> %rB, %rC
310         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
311                                   i8 -1, i8 -1, i8 -1, i8 -1,
312                                   i8 -1, i8 -1, i8 -1, i8 -1,
313                                   i8 -1, i8 -1, i8 -1, i8 -1 >
314         %B = and <16 x i8> %rA, %A
315         %D = or <16 x i8> %C, %B
316         ret <16 x i8> %D
317 }
318
319 ; (or (and rA, (not rC)), (and rB, rC))
320 define <16 x i8> @selectbits_v16i8_07(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
321         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
322                                   i8 -1, i8 -1, i8 -1, i8 -1,
323                                   i8 -1, i8 -1, i8 -1, i8 -1,
324                                   i8 -1, i8 -1, i8 -1, i8 -1 >
325         %B = and <16 x i8> %rA, %A
326         %C = and <16 x i8> %rB, %rC
327         %D = or <16 x i8> %C, %B
328         ret <16 x i8> %D
329 }
330
331 ; (or (and rA, (not rC)), (and rC, rB))
332 define <16 x i8> @selectbits_v16i8_08(<16 x i8> %rA, <16 x i8> %rB, <16 x i8> %rC) {
333         %A = xor <16 x i8> %rC, < i8 -1, i8 -1, i8 -1, i8 -1,
334                                   i8 -1, i8 -1, i8 -1, i8 -1,
335                                   i8 -1, i8 -1, i8 -1, i8 -1,
336                                   i8 -1, i8 -1, i8 -1, i8 -1 >
337         %B = and <16 x i8> %rA, %A
338         %C = and <16 x i8> %rC, %rB
339         %D = or <16 x i8> %C, %B
340         ret <16 x i8> %D
341 }
342
343 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
344 ; i32
345 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
346
347 ; (or (and rC, rB), (and (not rC), rA))
348 define i32 @selectbits_i32_01(i32 %rA, i32 %rB, i32 %rC) {
349         %C = and i32 %rC, %rB
350         %A = xor i32 %rC, -1
351         %B = and i32 %A, %rA
352         %D = or i32 %C, %B
353         ret i32 %D
354 }
355
356 ; (or (and rB, rC), (and (not rC), rA))
357 define i32 @selectbits_i32_02(i32 %rA, i32 %rB, i32 %rC) {
358         %C = and i32 %rB, %rC
359         %A = xor i32 %rC, -1
360         %B = and i32 %A, %rA
361         %D = or i32 %C, %B
362         ret i32 %D
363 }
364
365 ; (or (and (not rC), rA), (and rB, rC))
366 define i32 @selectbits_i32_03(i32 %rA, i32 %rB, i32 %rC) {
367         %A = xor i32 %rC, -1
368         %B = and i32 %A, %rA
369         %C = and i32 %rB, %rC
370         %D = or i32 %C, %B
371         ret i32 %D
372 }
373
374 ; (or (and (not rC), rA), (and rC, rB))
375 define i32 @selectbits_i32_04(i32 %rA, i32 %rB, i32 %rC) {
376         %A = xor i32 %rC, -1
377         %B = and i32 %A, %rA
378         %C = and i32 %rC, %rB
379         %D = or i32 %C, %B
380         ret i32 %D
381 }
382
383 ; (or (and rC, rB), (and rA, (not rC)))
384 define i32 @selectbits_i32_05(i32 %rA, i32 %rB, i32 %rC) {
385         %C = and i32 %rC, %rB
386         %A = xor i32 %rC, -1
387         %B = and i32 %rA, %A
388         %D = or i32 %C, %B
389         ret i32 %D
390 }
391
392 ; (or (and rB, rC), (and rA, (not rC)))
393 define i32 @selectbits_i32_06(i32 %rA, i32 %rB, i32 %rC) {
394         %C = and i32 %rB, %rC
395         %A = xor i32 %rC, -1
396         %B = and i32 %rA, %A
397         %D = or i32 %C, %B
398         ret i32 %D
399 }
400
401 ; (or (and rA, (not rC)), (and rB, rC))
402 define i32 @selectbits_i32_07(i32 %rA, i32 %rB, i32 %rC) {
403         %A = xor i32 %rC, -1
404         %B = and i32 %rA, %A
405         %C = and i32 %rB, %rC
406         %D = or i32 %C, %B
407         ret i32 %D
408 }
409
410 ; (or (and rA, (not rC)), (and rC, rB))
411 define i32 @selectbits_i32_08(i32 %rA, i32 %rB, i32 %rC) {
412         %A = xor i32 %rC, -1
413         %B = and i32 %rA, %A
414         %C = and i32 %rC, %rB
415         %D = or i32 %C, %B
416         ret i32 %D
417 }
418
419 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
420 ; i16
421 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
422
423 ; (or (and rC, rB), (and (not rC), rA))
424 define i16 @selectbits_i16_01(i16 %rA, i16 %rB, i16 %rC) {
425         %C = and i16 %rC, %rB
426         %A = xor i16 %rC, -1
427         %B = and i16 %A, %rA
428         %D = or i16 %C, %B
429         ret i16 %D
430 }
431
432 ; (or (and rB, rC), (and (not rC), rA))
433 define i16 @selectbits_i16_02(i16 %rA, i16 %rB, i16 %rC) {
434         %C = and i16 %rB, %rC
435         %A = xor i16 %rC, -1
436         %B = and i16 %A, %rA
437         %D = or i16 %C, %B
438         ret i16 %D
439 }
440
441 ; (or (and (not rC), rA), (and rB, rC))
442 define i16 @selectbits_i16_03(i16 %rA, i16 %rB, i16 %rC) {
443         %A = xor i16 %rC, -1
444         %B = and i16 %A, %rA
445         %C = and i16 %rB, %rC
446         %D = or i16 %C, %B
447         ret i16 %D
448 }
449
450 ; (or (and (not rC), rA), (and rC, rB))
451 define i16 @selectbits_i16_04(i16 %rA, i16 %rB, i16 %rC) {
452         %A = xor i16 %rC, -1
453         %B = and i16 %A, %rA
454         %C = and i16 %rC, %rB
455         %D = or i16 %C, %B
456         ret i16 %D
457 }
458
459 ; (or (and rC, rB), (and rA, (not rC)))
460 define i16 @selectbits_i16_05(i16 %rA, i16 %rB, i16 %rC) {
461         %C = and i16 %rC, %rB
462         %A = xor i16 %rC, -1
463         %B = and i16 %rA, %A
464         %D = or i16 %C, %B
465         ret i16 %D
466 }
467
468 ; (or (and rB, rC), (and rA, (not rC)))
469 define i16 @selectbits_i16_06(i16 %rA, i16 %rB, i16 %rC) {
470         %C = and i16 %rB, %rC
471         %A = xor i16 %rC, -1
472         %B = and i16 %rA, %A
473         %D = or i16 %C, %B
474         ret i16 %D
475 }
476
477 ; (or (and rA, (not rC)), (and rB, rC))
478 define i16 @selectbits_i16_07(i16 %rA, i16 %rB, i16 %rC) {
479         %A = xor i16 %rC, -1
480         %B = and i16 %rA, %A
481         %C = and i16 %rB, %rC
482         %D = or i16 %C, %B
483         ret i16 %D
484 }
485
486 ; (or (and rA, (not rC)), (and rC, rB))
487 define i16 @selectbits_i16_08(i16 %rA, i16 %rB, i16 %rC) {
488         %A = xor i16 %rC, -1
489         %B = and i16 %rA, %A
490         %C = and i16 %rC, %rB
491         %D = or i16 %C, %B
492         ret i16 %D
493 }
494
495 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
496 ; i8
497 ;-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
498
499 ; (or (and rC, rB), (and (not rC), rA))
500 define i8 @selectbits_i8_01(i8 %rA, i8 %rB, i8 %rC) {
501         %C = and i8 %rC, %rB
502         %A = xor i8 %rC, -1
503         %B = and i8 %A, %rA
504         %D = or i8 %C, %B
505         ret i8 %D
506 }
507
508 ; (or (and rB, rC), (and (not rC), rA))
509 define i8 @selectbits_i8_02(i8 %rA, i8 %rB, i8 %rC) {
510         %C = and i8 %rB, %rC
511         %A = xor i8 %rC, -1
512         %B = and i8 %A, %rA
513         %D = or i8 %C, %B
514         ret i8 %D
515 }
516
517 ; (or (and (not rC), rA), (and rB, rC))
518 define i8 @selectbits_i8_03(i8 %rA, i8 %rB, i8 %rC) {
519         %A = xor i8 %rC, -1
520         %B = and i8 %A, %rA
521         %C = and i8 %rB, %rC
522         %D = or i8 %C, %B
523         ret i8 %D
524 }
525
526 ; (or (and (not rC), rA), (and rC, rB))
527 define i8 @selectbits_i8_04(i8 %rA, i8 %rB, i8 %rC) {
528         %A = xor i8 %rC, -1
529         %B = and i8 %A, %rA
530         %C = and i8 %rC, %rB
531         %D = or i8 %C, %B
532         ret i8 %D
533 }
534
535 ; (or (and rC, rB), (and rA, (not rC)))
536 define i8 @selectbits_i8_05(i8 %rA, i8 %rB, i8 %rC) {
537         %C = and i8 %rC, %rB
538         %A = xor i8 %rC, -1
539         %B = and i8 %rA, %A
540         %D = or i8 %C, %B
541         ret i8 %D
542 }
543
544 ; (or (and rB, rC), (and rA, (not rC)))
545 define i8 @selectbits_i8_06(i8 %rA, i8 %rB, i8 %rC) {
546         %C = and i8 %rB, %rC
547         %A = xor i8 %rC, -1
548         %B = and i8 %rA, %A
549         %D = or i8 %C, %B
550         ret i8 %D
551 }
552
553 ; (or (and rA, (not rC)), (and rB, rC))
554 define i8 @selectbits_i8_07(i8 %rA, i8 %rB, i8 %rC) {
555         %A = xor i8 %rC, -1
556         %B = and i8 %rA, %A
557         %C = and i8 %rB, %rC
558         %D = or i8 %C, %B
559         ret i8 %D
560 }
561
562 ; (or (and rA, (not rC)), (and rC, rB))
563 define i8 @selectbits_i8_08(i8 %rA, i8 %rB, i8 %rC) {
564         %A = xor i8 %rC, -1
565         %B = and i8 %rA, %A
566         %C = and i8 %rC, %rB
567         %D = or i8 %C, %B
568         ret i8 %D
569 }