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: bif v0.8b, v1.8b, v2.8b
18 %mx = and <1 x i8> %x, %mask
19 %notmask = xor <1 x i8> %mask, <i8 -1>
20 %my = and <1 x i8> %y, %notmask
21 %r = or <1 x i8> %mx, %my
25 ; ============================================================================ ;
27 ; ============================================================================ ;
29 define <2 x i8> @out_v2i8(<2 x i8> %x, <2 x i8> %y, <2 x i8> %mask) nounwind {
30 ; CHECK-LABEL: out_v2i8:
32 ; CHECK-NEXT: movi d3, #0x0000ff000000ff
33 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
34 ; CHECK-NEXT: eor v3.8b, v2.8b, v3.8b
35 ; CHECK-NEXT: and v1.8b, v1.8b, v3.8b
36 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
38 %mx = and <2 x i8> %x, %mask
39 %notmask = xor <2 x i8> %mask, <i8 -1, i8 -1>
40 %my = and <2 x i8> %y, %notmask
41 %r = or <2 x i8> %mx, %my
45 define <1 x i16> @out_v1i16(<1 x i16> %x, <1 x i16> %y, <1 x i16> %mask) nounwind {
46 ; CHECK-LABEL: out_v1i16:
48 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
50 %mx = and <1 x i16> %x, %mask
51 %notmask = xor <1 x i16> %mask, <i16 -1>
52 %my = and <1 x i16> %y, %notmask
53 %r = or <1 x i16> %mx, %my
57 ; ============================================================================ ;
59 ; ============================================================================ ;
61 define <4 x i8> @out_v4i8(<4 x i8> %x, <4 x i8> %y, <4 x i8> %mask) nounwind {
62 ; CHECK-LABEL: out_v4i8:
64 ; CHECK-NEXT: movi d3, #0xff00ff00ff00ff
65 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
66 ; CHECK-NEXT: eor v3.8b, v2.8b, v3.8b
67 ; CHECK-NEXT: and v1.8b, v1.8b, v3.8b
68 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
70 %mx = and <4 x i8> %x, %mask
71 %notmask = xor <4 x i8> %mask, <i8 -1, i8 -1, i8 -1, i8 -1>
72 %my = and <4 x i8> %y, %notmask
73 %r = or <4 x i8> %mx, %my
77 define <4 x i8> @out_v4i8_undef(<4 x i8> %x, <4 x i8> %y, <4 x i8> %mask) nounwind {
78 ; CHECK-LABEL: out_v4i8_undef:
80 ; CHECK-NEXT: movi d3, #0xff00ff00ff00ff
81 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
82 ; CHECK-NEXT: eor v3.8b, v2.8b, v3.8b
83 ; CHECK-NEXT: and v1.8b, v1.8b, v3.8b
84 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
86 %mx = and <4 x i8> %x, %mask
87 %notmask = xor <4 x i8> %mask, <i8 -1, i8 -1, i8 undef, i8 -1>
88 %my = and <4 x i8> %y, %notmask
89 %r = or <4 x i8> %mx, %my
93 define <2 x i16> @out_v2i16(<2 x i16> %x, <2 x i16> %y, <2 x i16> %mask) nounwind {
94 ; CHECK-LABEL: out_v2i16:
96 ; CHECK-NEXT: movi d3, #0x00ffff0000ffff
97 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
98 ; CHECK-NEXT: eor v3.8b, v2.8b, v3.8b
99 ; CHECK-NEXT: and v1.8b, v1.8b, v3.8b
100 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
102 %mx = and <2 x i16> %x, %mask
103 %notmask = xor <2 x i16> %mask, <i16 -1, i16 -1>
104 %my = and <2 x i16> %y, %notmask
105 %r = or <2 x i16> %mx, %my
109 define <1 x i32> @out_v1i32(<1 x i32> %x, <1 x i32> %y, <1 x i32> %mask) nounwind {
110 ; CHECK-LABEL: out_v1i32:
112 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
114 %mx = and <1 x i32> %x, %mask
115 %notmask = xor <1 x i32> %mask, <i32 -1>
116 %my = and <1 x i32> %y, %notmask
117 %r = or <1 x i32> %mx, %my
121 ; ============================================================================ ;
122 ; 64-bit vector width
123 ; ============================================================================ ;
125 define <8 x i8> @out_v8i8(<8 x i8> %x, <8 x i8> %y, <8 x i8> %mask) nounwind {
126 ; CHECK-LABEL: out_v8i8:
128 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
130 %mx = and <8 x i8> %x, %mask
131 %notmask = xor <8 x i8> %mask, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
132 %my = and <8 x i8> %y, %notmask
133 %r = or <8 x i8> %mx, %my
137 define <4 x i16> @out_v4i16(<4 x i16> %x, <4 x i16> %y, <4 x i16> %mask) nounwind {
138 ; CHECK-LABEL: out_v4i16:
140 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
142 %mx = and <4 x i16> %x, %mask
143 %notmask = xor <4 x i16> %mask, <i16 -1, i16 -1, i16 -1, i16 -1>
144 %my = and <4 x i16> %y, %notmask
145 %r = or <4 x i16> %mx, %my
149 define <4 x i16> @out_v4i16_undef(<4 x i16> %x, <4 x i16> %y, <4 x i16> %mask) nounwind {
150 ; CHECK-LABEL: out_v4i16_undef:
152 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
154 %mx = and <4 x i16> %x, %mask
155 %notmask = xor <4 x i16> %mask, <i16 -1, i16 -1, i16 undef, i16 -1>
156 %my = and <4 x i16> %y, %notmask
157 %r = or <4 x i16> %mx, %my
161 define <2 x i32> @out_v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %mask) nounwind {
162 ; CHECK-LABEL: out_v2i32:
164 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
166 %mx = and <2 x i32> %x, %mask
167 %notmask = xor <2 x i32> %mask, <i32 -1, i32 -1>
168 %my = and <2 x i32> %y, %notmask
169 %r = or <2 x i32> %mx, %my
173 define <1 x i64> @out_v1i64(<1 x i64> %x, <1 x i64> %y, <1 x i64> %mask) nounwind {
174 ; CHECK-LABEL: out_v1i64:
176 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
178 %mx = and <1 x i64> %x, %mask
179 %notmask = xor <1 x i64> %mask, <i64 -1>
180 %my = and <1 x i64> %y, %notmask
181 %r = or <1 x i64> %mx, %my
185 ; ============================================================================ ;
186 ; 128-bit vector width
187 ; ============================================================================ ;
189 define <16 x i8> @out_v16i8(<16 x i8> %x, <16 x i8> %y, <16 x i8> %mask) nounwind {
190 ; CHECK-LABEL: out_v16i8:
192 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
194 %mx = and <16 x i8> %x, %mask
195 %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>
196 %my = and <16 x i8> %y, %notmask
197 %r = or <16 x i8> %mx, %my
201 define <8 x i16> @out_v8i16(<8 x i16> %x, <8 x i16> %y, <8 x i16> %mask) nounwind {
202 ; CHECK-LABEL: out_v8i16:
204 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
206 %mx = and <8 x i16> %x, %mask
207 %notmask = xor <8 x i16> %mask, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
208 %my = and <8 x i16> %y, %notmask
209 %r = or <8 x i16> %mx, %my
213 define <4 x i32> @out_v4i32(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) nounwind {
214 ; CHECK-LABEL: out_v4i32:
216 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
218 %mx = and <4 x i32> %x, %mask
219 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 -1, i32 -1>
220 %my = and <4 x i32> %y, %notmask
221 %r = or <4 x i32> %mx, %my
225 define <4 x i32> @out_v4i32_undef(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) nounwind {
226 ; CHECK-LABEL: out_v4i32_undef:
228 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
230 %mx = and <4 x i32> %x, %mask
231 %notmask = xor <4 x i32> %mask, <i32 -1, i32 -1, i32 undef, i32 -1>
232 %my = and <4 x i32> %y, %notmask
233 %r = or <4 x i32> %mx, %my
237 define <2 x i64> @out_v2i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %mask) nounwind {
238 ; CHECK-LABEL: out_v2i64:
240 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
242 %mx = and <2 x i64> %x, %mask
243 %notmask = xor <2 x i64> %mask, <i64 -1, i64 -1>
244 %my = and <2 x i64> %y, %notmask
245 %r = or <2 x i64> %mx, %my
249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
250 ; Should be the same as the previous one.
251 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253 ; ============================================================================ ;
255 ; ============================================================================ ;
257 define <1 x i8> @in_v1i8(<1 x i8> %x, <1 x i8> %y, <1 x i8> %mask) nounwind {
258 ; CHECK-LABEL: in_v1i8:
260 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
262 %n0 = xor <1 x i8> %x, %y
263 %n1 = and <1 x i8> %n0, %mask
264 %r = xor <1 x i8> %n1, %y
268 ; ============================================================================ ;
269 ; 16-bit vector width
270 ; ============================================================================ ;
272 define <2 x i8> @in_v2i8(<2 x i8> %x, <2 x i8> %y, <2 x i8> %mask) nounwind {
273 ; CHECK-LABEL: in_v2i8:
275 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
277 %n0 = xor <2 x i8> %x, %y
278 %n1 = and <2 x i8> %n0, %mask
279 %r = xor <2 x i8> %n1, %y
283 define <1 x i16> @in_v1i16(<1 x i16> %x, <1 x i16> %y, <1 x i16> %mask) nounwind {
284 ; CHECK-LABEL: in_v1i16:
286 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
288 %n0 = xor <1 x i16> %x, %y
289 %n1 = and <1 x i16> %n0, %mask
290 %r = xor <1 x i16> %n1, %y
294 ; ============================================================================ ;
295 ; 32-bit vector width
296 ; ============================================================================ ;
298 define <4 x i8> @in_v4i8(<4 x i8> %x, <4 x i8> %y, <4 x i8> %mask) nounwind {
299 ; CHECK-LABEL: in_v4i8:
301 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
303 %n0 = xor <4 x i8> %x, %y
304 %n1 = and <4 x i8> %n0, %mask
305 %r = xor <4 x i8> %n1, %y
309 define <2 x i16> @in_v2i16(<2 x i16> %x, <2 x i16> %y, <2 x i16> %mask) nounwind {
310 ; CHECK-LABEL: in_v2i16:
312 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
314 %n0 = xor <2 x i16> %x, %y
315 %n1 = and <2 x i16> %n0, %mask
316 %r = xor <2 x i16> %n1, %y
320 define <1 x i32> @in_v1i32(<1 x i32> %x, <1 x i32> %y, <1 x i32> %mask) nounwind {
321 ; CHECK-LABEL: in_v1i32:
323 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
325 %n0 = xor <1 x i32> %x, %y
326 %n1 = and <1 x i32> %n0, %mask
327 %r = xor <1 x i32> %n1, %y
331 ; ============================================================================ ;
332 ; 64-bit vector width
333 ; ============================================================================ ;
335 define <8 x i8> @in_v8i8(<8 x i8> %x, <8 x i8> %y, <8 x i8> %mask) nounwind {
336 ; CHECK-LABEL: in_v8i8:
338 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
340 %n0 = xor <8 x i8> %x, %y
341 %n1 = and <8 x i8> %n0, %mask
342 %r = xor <8 x i8> %n1, %y
346 define <4 x i16> @in_v4i16(<4 x i16> %x, <4 x i16> %y, <4 x i16> %mask) nounwind {
347 ; CHECK-LABEL: in_v4i16:
349 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
351 %n0 = xor <4 x i16> %x, %y
352 %n1 = and <4 x i16> %n0, %mask
353 %r = xor <4 x i16> %n1, %y
357 define <2 x i32> @in_v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %mask) nounwind {
358 ; CHECK-LABEL: in_v2i32:
360 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
362 %n0 = xor <2 x i32> %x, %y
363 %n1 = and <2 x i32> %n0, %mask
364 %r = xor <2 x i32> %n1, %y
368 define <1 x i64> @in_v1i64(<1 x i64> %x, <1 x i64> %y, <1 x i64> %mask) nounwind {
369 ; CHECK-LABEL: in_v1i64:
371 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
373 %n0 = xor <1 x i64> %x, %y
374 %n1 = and <1 x i64> %n0, %mask
375 %r = xor <1 x i64> %n1, %y
379 ; ============================================================================ ;
380 ; 128-bit vector width
381 ; ============================================================================ ;
383 define <16 x i8> @in_v16i8(<16 x i8> %x, <16 x i8> %y, <16 x i8> %mask) nounwind {
384 ; CHECK-LABEL: in_v16i8:
386 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
388 %n0 = xor <16 x i8> %x, %y
389 %n1 = and <16 x i8> %n0, %mask
390 %r = xor <16 x i8> %n1, %y
394 define <8 x i16> @in_v8i16(<8 x i16> %x, <8 x i16> %y, <8 x i16> %mask) nounwind {
395 ; CHECK-LABEL: in_v8i16:
397 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
399 %n0 = xor <8 x i16> %x, %y
400 %n1 = and <8 x i16> %n0, %mask
401 %r = xor <8 x i16> %n1, %y
405 define <4 x i32> @in_v4i32(<4 x i32> %x, <4 x i32> %y, <4 x i32> %mask) nounwind {
406 ; CHECK-LABEL: in_v4i32:
408 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
410 %n0 = xor <4 x i32> %x, %y
411 %n1 = and <4 x i32> %n0, %mask
412 %r = xor <4 x i32> %n1, %y
416 define <2 x i64> @in_v2i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %mask) nounwind {
417 ; CHECK-LABEL: in_v2i64:
419 ; CHECK-NEXT: bif v0.16b, v1.16b, v2.16b
421 %n0 = xor <2 x i64> %x, %y
422 %n1 = and <2 x i64> %n0, %mask
423 %r = xor <2 x i64> %n1, %y