1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
4 ; https://bugs.llvm.org/show_bug.cgi?id=37104
6 ; All the advanced stuff (negative tests, commutativity) is handled in the
7 ; scalar version of the test only.
9 ; ============================================================================ ;
11 ; ============================================================================ ;
13 define <1 x i8> @out_v1i8(<1 x i8> %x, <1 x i8> %y, <1 x i8> %mask) nounwind {
14 ; CHECK-LABEL: out_v1i8:
16 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
17 ; CHECK-NEXT: mov v0.16b, v2.16b
19 %mx = and <1 x i8> %x, %mask
20 %notmask = xor <1 x i8> %mask, <i8 -1>
21 %my = and <1 x i8> %y, %notmask
22 %r = or <1 x i8> %mx, %my
26 ; ============================================================================ ;
28 ; ============================================================================ ;
30 define <2 x i8> @out_v2i8(<2 x i8> %x, <2 x i8> %y, <2 x i8> %mask) nounwind {
31 ; CHECK-LABEL: out_v2i8:
33 ; CHECK-NEXT: movi d3, #0x0000ff000000ff
34 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
35 ; CHECK-NEXT: eor v2.8b, v2.8b, v3.8b
36 ; CHECK-NEXT: and v1.8b, v1.8b, v2.8b
37 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
39 %mx = and <2 x i8> %x, %mask
40 %notmask = xor <2 x i8> %mask, <i8 -1, i8 -1>
41 %my = and <2 x i8> %y, %notmask
42 %r = or <2 x i8> %mx, %my
46 define <1 x i16> @out_v1i16(<1 x i16> %x, <1 x i16> %y, <1 x i16> %mask) nounwind {
47 ; CHECK-LABEL: out_v1i16:
49 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
50 ; CHECK-NEXT: mov v0.16b, v2.16b
52 %mx = and <1 x i16> %x, %mask
53 %notmask = xor <1 x i16> %mask, <i16 -1>
54 %my = and <1 x i16> %y, %notmask
55 %r = or <1 x i16> %mx, %my
59 ; ============================================================================ ;
61 ; ============================================================================ ;
63 define <4 x i8> @out_v4i8(<4 x i8> %x, <4 x i8> %y, <4 x i8> %mask) nounwind {
64 ; CHECK-LABEL: out_v4i8:
66 ; CHECK-NEXT: movi d3, #0xff00ff00ff00ff
67 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
68 ; CHECK-NEXT: eor v2.8b, v2.8b, v3.8b
69 ; CHECK-NEXT: and v1.8b, v1.8b, v2.8b
70 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
72 %mx = and <4 x i8> %x, %mask
73 %notmask = xor <4 x i8> %mask, <i8 -1, i8 -1, i8 -1, i8 -1>
74 %my = and <4 x i8> %y, %notmask
75 %r = or <4 x i8> %mx, %my
79 define <4 x i8> @out_v4i8_undef(<4 x i8> %x, <4 x i8> %y, <4 x i8> %mask) nounwind {
80 ; CHECK-LABEL: out_v4i8_undef:
82 ; CHECK-NEXT: movi d3, #0xff00ff00ff00ff
83 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
84 ; CHECK-NEXT: eor v2.8b, v2.8b, v3.8b
85 ; CHECK-NEXT: and v1.8b, v1.8b, v2.8b
86 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
88 %mx = and <4 x i8> %x, %mask
89 %notmask = xor <4 x i8> %mask, <i8 -1, i8 -1, i8 undef, i8 -1>
90 %my = and <4 x i8> %y, %notmask
91 %r = or <4 x i8> %mx, %my
95 define <2 x i16> @out_v2i16(<2 x i16> %x, <2 x i16> %y, <2 x i16> %mask) nounwind {
96 ; CHECK-LABEL: out_v2i16:
98 ; CHECK-NEXT: movi d3, #0x00ffff0000ffff
99 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
100 ; CHECK-NEXT: eor v2.8b, v2.8b, v3.8b
101 ; CHECK-NEXT: and v1.8b, v1.8b, v2.8b
102 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
104 %mx = and <2 x i16> %x, %mask
105 %notmask = xor <2 x i16> %mask, <i16 -1, i16 -1>
106 %my = and <2 x i16> %y, %notmask
107 %r = or <2 x i16> %mx, %my
111 define <1 x i32> @out_v1i32(<1 x i32> %x, <1 x i32> %y, <1 x i32> %mask) nounwind {
112 ; CHECK-LABEL: out_v1i32:
114 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
115 ; CHECK-NEXT: mov v0.16b, v2.16b
117 %mx = and <1 x i32> %x, %mask
118 %notmask = xor <1 x i32> %mask, <i32 -1>
119 %my = and <1 x i32> %y, %notmask
120 %r = or <1 x i32> %mx, %my
124 ; ============================================================================ ;
125 ; 64-bit vector width
126 ; ============================================================================ ;
128 define <8 x i8> @out_v8i8(<8 x i8> %x, <8 x i8> %y, <8 x i8> %mask) nounwind {
129 ; CHECK-LABEL: out_v8i8:
131 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
132 ; CHECK-NEXT: mov v0.16b, v2.16b
134 %mx = and <8 x i8> %x, %mask
135 %notmask = xor <8 x i8> %mask, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
136 %my = and <8 x i8> %y, %notmask
137 %r = or <8 x i8> %mx, %my
141 define <4 x i16> @out_v4i16(<4 x i16> %x, <4 x i16> %y, <4 x i16> %mask) nounwind {
142 ; CHECK-LABEL: out_v4i16:
144 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
145 ; CHECK-NEXT: mov v0.16b, v2.16b
147 %mx = and <4 x i16> %x, %mask
148 %notmask = xor <4 x i16> %mask, <i16 -1, i16 -1, i16 -1, i16 -1>
149 %my = and <4 x i16> %y, %notmask
150 %r = or <4 x i16> %mx, %my
154 define <4 x i16> @out_v4i16_undef(<4 x i16> %x, <4 x i16> %y, <4 x i16> %mask) nounwind {
155 ; CHECK-LABEL: out_v4i16_undef:
157 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
158 ; CHECK-NEXT: mov v0.16b, v2.16b
160 %mx = and <4 x i16> %x, %mask
161 %notmask = xor <4 x i16> %mask, <i16 -1, i16 -1, i16 undef, i16 -1>
162 %my = and <4 x i16> %y, %notmask
163 %r = or <4 x i16> %mx, %my
167 define <2 x i32> @out_v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %mask) nounwind {
168 ; CHECK-LABEL: out_v2i32:
170 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
171 ; CHECK-NEXT: mov v0.16b, v2.16b
173 %mx = and <2 x i32> %x, %mask
174 %notmask = xor <2 x i32> %mask, <i32 -1, i32 -1>
175 %my = and <2 x i32> %y, %notmask
176 %r = or <2 x i32> %mx, %my
180 define <1 x i64> @out_v1i64(<1 x i64> %x, <1 x i64> %y, <1 x i64> %mask) nounwind {
181 ; CHECK-LABEL: out_v1i64:
183 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
184 ; CHECK-NEXT: mov v0.16b, v2.16b
186 %mx = and <1 x i64> %x, %mask
187 %notmask = xor <1 x i64> %mask, <i64 -1>
188 %my = and <1 x i64> %y, %notmask
189 %r = or <1 x i64> %mx, %my
193 ; ============================================================================ ;
194 ; 128-bit vector width
195 ; ============================================================================ ;
197 define <16 x i8> @out_v16i8(<16 x i8> %x, <16 x i8> %y, <16 x i8> %mask) nounwind {
198 ; CHECK-LABEL: out_v16i8:
200 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
201 ; CHECK-NEXT: mov v0.16b, v2.16b
203 %mx = and <16 x i8> %x, %mask
204 %notmask = xor <16 x i8> %mask, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
205 %my = and <16 x i8> %y, %notmask
206 %r = or <16 x i8> %mx, %my
210 define <8 x i16> @out_v8i16(<8 x i16> %x, <8 x i16> %y, <8 x i16> %mask) nounwind {
211 ; CHECK-LABEL: out_v8i16:
213 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
214 ; CHECK-NEXT: mov v0.16b, v2.16b
216 %mx = and <8 x i16> %x, %mask
217 %notmask = xor <8 x i16> %mask, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
218 %my = and <8 x i16> %y, %notmask
219 %r = or <8 x i16> %mx, %my
223 define <4 x i32> @out_v4i32(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) nounwind {
224 ; CHECK-LABEL: out_v4i32:
226 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
227 ; CHECK-NEXT: mov v0.16b, v2.16b
229 %mx = and <4 x i32> %x, %mask
230 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
231 %my = and <4 x i32> %y, %notmask
232 %r = or <4 x i32> %mx, %my
236 define <4 x i32> @out_v4i32_undef(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) nounwind {
237 ; CHECK-LABEL: out_v4i32_undef:
239 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
240 ; CHECK-NEXT: mov v0.16b, v2.16b
242 %mx = and <4 x i32> %x, %mask
243 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 undef, i32 -1>
244 %my = and <4 x i32> %y, %notmask
245 %r = or <4 x i32> %mx, %my
249 define <2 x i64> @out_v2i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %mask) nounwind {
250 ; CHECK-LABEL: out_v2i64:
252 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
253 ; CHECK-NEXT: mov v0.16b, v2.16b
255 %mx = and <2 x i64> %x, %mask
256 %notmask = xor <2 x i64> %mask, <i64 -1, i64 -1>
257 %my = and <2 x i64> %y, %notmask
258 %r = or <2 x i64> %mx, %my
262 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
263 ; Should be the same as the previous one.
264 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
266 ; ============================================================================ ;
268 ; ============================================================================ ;
270 define <1 x i8> @in_v1i8(<1 x i8> %x, <1 x i8> %y, <1 x i8> %mask) nounwind {
271 ; CHECK-LABEL: in_v1i8:
273 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
274 ; CHECK-NEXT: mov v0.16b, v2.16b
276 %n0 = xor <1 x i8> %x, %y
277 %n1 = and <1 x i8> %n0, %mask
278 %r = xor <1 x i8> %n1, %y
282 ; ============================================================================ ;
283 ; 16-bit vector width
284 ; ============================================================================ ;
286 define <2 x i8> @in_v2i8(<2 x i8> %x, <2 x i8> %y, <2 x i8> %mask) nounwind {
287 ; CHECK-LABEL: in_v2i8:
289 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
290 ; CHECK-NEXT: mov v0.16b, v2.16b
292 %n0 = xor <2 x i8> %x, %y
293 %n1 = and <2 x i8> %n0, %mask
294 %r = xor <2 x i8> %n1, %y
298 define <1 x i16> @in_v1i16(<1 x i16> %x, <1 x i16> %y, <1 x i16> %mask) nounwind {
299 ; CHECK-LABEL: in_v1i16:
301 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
302 ; CHECK-NEXT: mov v0.16b, v2.16b
304 %n0 = xor <1 x i16> %x, %y
305 %n1 = and <1 x i16> %n0, %mask
306 %r = xor <1 x i16> %n1, %y
310 ; ============================================================================ ;
311 ; 32-bit vector width
312 ; ============================================================================ ;
314 define <4 x i8> @in_v4i8(<4 x i8> %x, <4 x i8> %y, <4 x i8> %mask) nounwind {
315 ; CHECK-LABEL: in_v4i8:
317 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
318 ; CHECK-NEXT: mov v0.16b, v2.16b
320 %n0 = xor <4 x i8> %x, %y
321 %n1 = and <4 x i8> %n0, %mask
322 %r = xor <4 x i8> %n1, %y
326 define <2 x i16> @in_v2i16(<2 x i16> %x, <2 x i16> %y, <2 x i16> %mask) nounwind {
327 ; CHECK-LABEL: in_v2i16:
329 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
330 ; CHECK-NEXT: mov v0.16b, v2.16b
332 %n0 = xor <2 x i16> %x, %y
333 %n1 = and <2 x i16> %n0, %mask
334 %r = xor <2 x i16> %n1, %y
338 define <1 x i32> @in_v1i32(<1 x i32> %x, <1 x i32> %y, <1 x i32> %mask) nounwind {
339 ; CHECK-LABEL: in_v1i32:
341 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
342 ; CHECK-NEXT: mov v0.16b, v2.16b
344 %n0 = xor <1 x i32> %x, %y
345 %n1 = and <1 x i32> %n0, %mask
346 %r = xor <1 x i32> %n1, %y
350 ; ============================================================================ ;
351 ; 64-bit vector width
352 ; ============================================================================ ;
354 define <8 x i8> @in_v8i8(<8 x i8> %x, <8 x i8> %y, <8 x i8> %mask) nounwind {
355 ; CHECK-LABEL: in_v8i8:
357 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
358 ; CHECK-NEXT: mov v0.16b, v2.16b
360 %n0 = xor <8 x i8> %x, %y
361 %n1 = and <8 x i8> %n0, %mask
362 %r = xor <8 x i8> %n1, %y
366 define <4 x i16> @in_v4i16(<4 x i16> %x, <4 x i16> %y, <4 x i16> %mask) nounwind {
367 ; CHECK-LABEL: in_v4i16:
369 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
370 ; CHECK-NEXT: mov v0.16b, v2.16b
372 %n0 = xor <4 x i16> %x, %y
373 %n1 = and <4 x i16> %n0, %mask
374 %r = xor <4 x i16> %n1, %y
378 define <2 x i32> @in_v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %mask) nounwind {
379 ; CHECK-LABEL: in_v2i32:
381 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
382 ; CHECK-NEXT: mov v0.16b, v2.16b
384 %n0 = xor <2 x i32> %x, %y
385 %n1 = and <2 x i32> %n0, %mask
386 %r = xor <2 x i32> %n1, %y
390 define <1 x i64> @in_v1i64(<1 x i64> %x, <1 x i64> %y, <1 x i64> %mask) nounwind {
391 ; CHECK-LABEL: in_v1i64:
393 ; CHECK-NEXT: bsl v2.8b, v0.8b, v1.8b
394 ; CHECK-NEXT: mov v0.16b, v2.16b
396 %n0 = xor <1 x i64> %x, %y
397 %n1 = and <1 x i64> %n0, %mask
398 %r = xor <1 x i64> %n1, %y
402 ; ============================================================================ ;
403 ; 128-bit vector width
404 ; ============================================================================ ;
406 define <16 x i8> @in_v16i8(<16 x i8> %x, <16 x i8> %y, <16 x i8> %mask) nounwind {
407 ; CHECK-LABEL: in_v16i8:
409 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
410 ; CHECK-NEXT: mov v0.16b, v2.16b
412 %n0 = xor <16 x i8> %x, %y
413 %n1 = and <16 x i8> %n0, %mask
414 %r = xor <16 x i8> %n1, %y
418 define <8 x i16> @in_v8i16(<8 x i16> %x, <8 x i16> %y, <8 x i16> %mask) nounwind {
419 ; CHECK-LABEL: in_v8i16:
421 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
422 ; CHECK-NEXT: mov v0.16b, v2.16b
424 %n0 = xor <8 x i16> %x, %y
425 %n1 = and <8 x i16> %n0, %mask
426 %r = xor <8 x i16> %n1, %y
430 define <4 x i32> @in_v4i32(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) nounwind {
431 ; CHECK-LABEL: in_v4i32:
433 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
434 ; CHECK-NEXT: mov v0.16b, v2.16b
436 %n0 = xor <4 x i32> %x, %y
437 %n1 = and <4 x i32> %n0, %mask
438 %r = xor <4 x i32> %n1, %y
442 define <2 x i64> @in_v2i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %mask) nounwind {
443 ; CHECK-LABEL: in_v2i64:
445 ; CHECK-NEXT: bsl v2.16b, v0.16b, v1.16b
446 ; CHECK-NEXT: mov v0.16b, v2.16b
448 %n0 = xor <2 x i64> %x, %y
449 %n1 = and <2 x i64> %n0, %mask
450 %r = xor <2 x i64> %n1, %y