1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64 | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc < %s -global-isel -mtriple=aarch64 | FileCheck %s --check-prefixes=CHECK,CHECK-GISEL
5 ; Tests of shufflevector where the index operand is half the width of the vector
6 ; operands. We should get one ext instruction and not two.
9 define <8 x i8> @i8_off0(<16 x i8> %arg1, <16 x i8> %arg2) {
10 ; CHECK-LABEL: i8_off0:
11 ; CHECK: // %bb.0: // %entry
12 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
15 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> %arg2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
19 define <8 x i8> @i8_off1(<16 x i8> %arg1, <16 x i8> %arg2) {
20 ; CHECK-SD-LABEL: i8_off1:
21 ; CHECK-SD: // %bb.0: // %entry
22 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #1
23 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
26 ; CHECK-GISEL-LABEL: i8_off1:
27 ; CHECK-GISEL: // %bb.0: // %entry
28 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #1
29 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
30 ; CHECK-GISEL-NEXT: ret
32 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> %arg2, <8 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
36 define <8 x i8> @i8_off8(<16 x i8> %arg1, <16 x i8> %arg2) {
37 ; CHECK-SD-LABEL: i8_off8:
38 ; CHECK-SD: // %bb.0: // %entry
39 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #8
40 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
43 ; CHECK-GISEL-LABEL: i8_off8:
44 ; CHECK-GISEL: // %bb.0: // %entry
45 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #8
46 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
47 ; CHECK-GISEL-NEXT: ret
49 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> %arg2, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
53 define <8 x i8> @i8_off15(<16 x i8> %arg1, <16 x i8> %arg2) {
54 ; CHECK-LABEL: i8_off15:
55 ; CHECK: // %bb.0: // %entry
56 ; CHECK-NEXT: ext v0.16b, v0.16b, v1.16b, #15
57 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
60 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> %arg2, <8 x i32> <i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22>
64 define <8 x i8> @i8_off22(<16 x i8> %arg1, <16 x i8> %arg2) {
65 ; CHECK-SD-LABEL: i8_off22:
66 ; CHECK-SD: // %bb.0: // %entry
67 ; CHECK-SD-NEXT: ext v0.16b, v1.16b, v1.16b, #6
68 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
71 ; CHECK-GISEL-LABEL: i8_off22:
72 ; CHECK-GISEL: // %bb.0: // %entry
73 ; CHECK-GISEL-NEXT: ext v0.16b, v1.16b, v0.16b, #6
74 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
75 ; CHECK-GISEL-NEXT: ret
77 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> %arg2, <8 x i32> <i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29>
82 define <4 x i16> @i16_off0(<8 x i16> %arg1, <8 x i16> %arg2) {
83 ; CHECK-LABEL: i16_off0:
84 ; CHECK: // %bb.0: // %entry
85 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
88 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
89 ret <4 x i16> %shuffle
92 define <4 x i16> @i16_off1(<8 x i16> %arg1, <8 x i16> %arg2) {
93 ; CHECK-SD-LABEL: i16_off1:
94 ; CHECK-SD: // %bb.0: // %entry
95 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #2
96 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
99 ; CHECK-GISEL-LABEL: i16_off1:
100 ; CHECK-GISEL: // %bb.0: // %entry
101 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #2
102 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
103 ; CHECK-GISEL-NEXT: ret
105 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
106 ret <4 x i16> %shuffle
109 define <4 x i16> @i16_off7(<8 x i16> %arg1, <8 x i16> %arg2) {
110 ; CHECK-LABEL: i16_off7:
111 ; CHECK: // %bb.0: // %entry
112 ; CHECK-NEXT: ext v0.16b, v0.16b, v1.16b, #14
113 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
116 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 7, i32 8, i32 9, i32 10>
117 ret <4 x i16> %shuffle
120 define <4 x i16> @i16_off8(<8 x i16> %arg1, <8 x i16> %arg2) {
121 ; CHECK-LABEL: i16_off8:
122 ; CHECK: // %bb.0: // %entry
123 ; CHECK-NEXT: mov v0.16b, v1.16b
124 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
127 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 8, i32 9, i32 10, i32 11>
128 ret <4 x i16> %shuffle
132 define <2 x i32> @i32_off0(<4 x i32> %arg1, <4 x i32> %arg2) {
133 ; CHECK-LABEL: i32_off0:
134 ; CHECK: // %bb.0: // %entry
135 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
138 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 0, i32 1>
139 ret <2 x i32> %shuffle
142 define <2 x i32> @i32_off1(<4 x i32> %arg1, <4 x i32> %arg2) {
143 ; CHECK-SD-LABEL: i32_off1:
144 ; CHECK-SD: // %bb.0: // %entry
145 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #4
146 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
149 ; CHECK-GISEL-LABEL: i32_off1:
150 ; CHECK-GISEL: // %bb.0: // %entry
151 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #4
152 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
153 ; CHECK-GISEL-NEXT: ret
155 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 1, i32 2>
156 ret <2 x i32> %shuffle
159 define <2 x i32> @i32_off3(<4 x i32> %arg1, <4 x i32> %arg2) {
160 ; CHECK-LABEL: i32_off3:
161 ; CHECK: // %bb.0: // %entry
162 ; CHECK-NEXT: ext v0.16b, v0.16b, v1.16b, #12
163 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
166 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 3, i32 4>
167 ret <2 x i32> %shuffle
170 define <2 x i32> @i32_off4(<4 x i32> %arg1, <4 x i32> %arg2) {
171 ; CHECK-LABEL: i32_off4:
172 ; CHECK: // %bb.0: // %entry
173 ; CHECK-NEXT: mov v0.16b, v1.16b
174 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
177 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 4, i32 5>
178 ret <2 x i32> %shuffle
182 define <1 x i64> @i64_off0(<2 x i64> %arg1, <2 x i64> %arg2) {
183 ; CHECK-LABEL: i64_off0:
184 ; CHECK: // %bb.0: // %entry
185 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
188 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> %arg2, <1 x i32> <i32 0>
189 ret <1 x i64> %shuffle
192 define <1 x i64> @i64_off1(<2 x i64> %arg1, <2 x i64> %arg2) {
193 ; CHECK-SD-LABEL: i64_off1:
194 ; CHECK-SD: // %bb.0: // %entry
195 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #8
196 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
199 ; CHECK-GISEL-LABEL: i64_off1:
200 ; CHECK-GISEL: // %bb.0: // %entry
201 ; CHECK-GISEL-NEXT: mov d0, v0.d[1]
202 ; CHECK-GISEL-NEXT: ret
204 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> %arg2, <1 x i32> <i32 1>
205 ret <1 x i64> %shuffle
208 define <1 x i64> @i64_off2(<2 x i64> %arg1, <2 x i64> %arg2) {
209 ; CHECK-LABEL: i64_off2:
210 ; CHECK: // %bb.0: // %entry
211 ; CHECK-NEXT: mov v0.16b, v1.16b
212 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
215 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> %arg2, <1 x i32> <i32 2>
216 ret <1 x i64> %shuffle
219 ; i8 tests with second operand zero
220 define <8 x i8> @i8_zero_off0(<16 x i8> %arg1) {
221 ; CHECK-LABEL: i8_zero_off0:
222 ; CHECK: // %bb.0: // %entry
223 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
226 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
227 ret <8 x i8> %shuffle
230 define <8 x i8> @i8_zero_off1(<16 x i8> %arg1) {
231 ; CHECK-SD-LABEL: i8_zero_off1:
232 ; CHECK-SD: // %bb.0: // %entry
233 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #1
234 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
237 ; CHECK-GISEL-LABEL: i8_zero_off1:
238 ; CHECK-GISEL: // %bb.0: // %entry
239 ; CHECK-GISEL-NEXT: movi v1.2d, #0000000000000000
240 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #1
241 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
242 ; CHECK-GISEL-NEXT: ret
244 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> zeroinitializer, <8 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
245 ret <8 x i8> %shuffle
248 define <8 x i8> @i8_zero_off8(<16 x i8> %arg1) {
249 ; CHECK-SD-LABEL: i8_zero_off8:
250 ; CHECK-SD: // %bb.0: // %entry
251 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #8
252 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
255 ; CHECK-GISEL-LABEL: i8_zero_off8:
256 ; CHECK-GISEL: // %bb.0: // %entry
257 ; CHECK-GISEL-NEXT: movi v1.2d, #0000000000000000
258 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #8
259 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
260 ; CHECK-GISEL-NEXT: ret
262 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> zeroinitializer, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
263 ret <8 x i8> %shuffle
266 define <8 x i8> @i8_zero_off15(<16 x i8> %arg1) {
267 ; CHECK-LABEL: i8_zero_off15:
268 ; CHECK: // %bb.0: // %entry
269 ; CHECK-NEXT: movi v1.2d, #0000000000000000
270 ; CHECK-NEXT: ext v0.16b, v0.16b, v1.16b, #15
271 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
274 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> zeroinitializer, <8 x i32> <i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22>
275 ret <8 x i8> %shuffle
278 define <8 x i8> @i8_zero_off22(<16 x i8> %arg1) {
279 ; CHECK-SD-LABEL: i8_zero_off22:
280 ; CHECK-SD: // %bb.0: // %entry
281 ; CHECK-SD-NEXT: movi v0.2d, #0000000000000000
284 ; CHECK-GISEL-LABEL: i8_zero_off22:
285 ; CHECK-GISEL: // %bb.0: // %entry
286 ; CHECK-GISEL-NEXT: movi v1.2d, #0000000000000000
287 ; CHECK-GISEL-NEXT: ext v0.16b, v1.16b, v0.16b, #6
288 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
289 ; CHECK-GISEL-NEXT: ret
291 %shuffle = shufflevector <16 x i8> %arg1, <16 x i8> zeroinitializer, <8 x i32> <i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29>
292 ret <8 x i8> %shuffle
295 ; i16 tests with second operand zero
296 define <4 x i16> @i16_zero_off0(<8 x i16> %arg1) {
297 ; CHECK-LABEL: i16_zero_off0:
298 ; CHECK: // %bb.0: // %entry
299 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
302 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
303 ret <4 x i16> %shuffle
306 define <4 x i16> @i16_zero_off1(<8 x i16> %arg1) {
307 ; CHECK-SD-LABEL: i16_zero_off1:
308 ; CHECK-SD: // %bb.0: // %entry
309 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #2
310 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
313 ; CHECK-GISEL-LABEL: i16_zero_off1:
314 ; CHECK-GISEL: // %bb.0: // %entry
315 ; CHECK-GISEL-NEXT: movi v1.2d, #0000000000000000
316 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #2
317 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
318 ; CHECK-GISEL-NEXT: ret
320 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
321 ret <4 x i16> %shuffle
324 define <4 x i16> @i16_zero_off7(<8 x i16> %arg1) {
325 ; CHECK-LABEL: i16_zero_off7:
326 ; CHECK: // %bb.0: // %entry
327 ; CHECK-NEXT: movi v1.2d, #0000000000000000
328 ; CHECK-NEXT: ext v0.16b, v0.16b, v1.16b, #14
329 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
332 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 7, i32 8, i32 9, i32 10>
333 ret <4 x i16> %shuffle
336 define <4 x i16> @i16_zero_off8(<8 x i16> %arg1) {
337 ; CHECK-LABEL: i16_zero_off8:
338 ; CHECK: // %bb.0: // %entry
339 ; CHECK-NEXT: movi v0.2d, #0000000000000000
342 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 8, i32 9, i32 10, i32 11>
343 ret <4 x i16> %shuffle
346 ; i32 tests with second operand zero
347 define <2 x i32> @i32_zero_off0(<4 x i32> %arg1) {
348 ; CHECK-LABEL: i32_zero_off0:
349 ; CHECK: // %bb.0: // %entry
350 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
353 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 0, i32 1>
354 ret <2 x i32> %shuffle
357 define <2 x i32> @i32_zero_off1(<4 x i32> %arg1) {
358 ; CHECK-SD-LABEL: i32_zero_off1:
359 ; CHECK-SD: // %bb.0: // %entry
360 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #4
361 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
364 ; CHECK-GISEL-LABEL: i32_zero_off1:
365 ; CHECK-GISEL: // %bb.0: // %entry
366 ; CHECK-GISEL-NEXT: movi v1.2d, #0000000000000000
367 ; CHECK-GISEL-NEXT: ext v0.16b, v0.16b, v1.16b, #4
368 ; CHECK-GISEL-NEXT: // kill: def $d0 killed $d0 killed $q0
369 ; CHECK-GISEL-NEXT: ret
371 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 1, i32 2>
372 ret <2 x i32> %shuffle
375 define <2 x i32> @i32_zero_off3(<4 x i32> %arg1) {
376 ; CHECK-LABEL: i32_zero_off3:
377 ; CHECK: // %bb.0: // %entry
378 ; CHECK-NEXT: movi v1.2d, #0000000000000000
379 ; CHECK-NEXT: ext v0.16b, v0.16b, v1.16b, #12
380 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
383 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 3, i32 4>
384 ret <2 x i32> %shuffle
387 define <2 x i32> @i32_zero_off4(<4 x i32> %arg1) {
388 ; CHECK-LABEL: i32_zero_off4:
389 ; CHECK: // %bb.0: // %entry
390 ; CHECK-NEXT: movi v0.2d, #0000000000000000
393 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 4, i32 5>
394 ret <2 x i32> %shuffle
397 ; i64 tests with second operand zero
398 define <1 x i64> @i64_zero_off0(<2 x i64> %arg1) {
399 ; CHECK-LABEL: i64_zero_off0:
400 ; CHECK: // %bb.0: // %entry
401 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
404 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> zeroinitializer, <1 x i32> <i32 0>
405 ret <1 x i64> %shuffle
408 define <1 x i64> @i64_zero_off1(<2 x i64> %arg1) {
409 ; CHECK-SD-LABEL: i64_zero_off1:
410 ; CHECK-SD: // %bb.0: // %entry
411 ; CHECK-SD-NEXT: ext v0.16b, v0.16b, v0.16b, #8
412 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
415 ; CHECK-GISEL-LABEL: i64_zero_off1:
416 ; CHECK-GISEL: // %bb.0: // %entry
417 ; CHECK-GISEL-NEXT: mov d0, v0.d[1]
418 ; CHECK-GISEL-NEXT: ret
420 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> zeroinitializer, <1 x i32> <i32 1>
421 ret <1 x i64> %shuffle
424 define <1 x i64> @i64_zero_off2(<2 x i64> %arg1) {
425 ; CHECK-LABEL: i64_zero_off2:
426 ; CHECK: // %bb.0: // %entry
427 ; CHECK-NEXT: fmov d0, xzr
430 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> zeroinitializer, <1 x i32> <i32 2>
431 ret <1 x i64> %shuffle