1 ; RUN: llc < %s -mtriple=aarch64 | FileCheck %s
3 ; Tests of shufflevector where the index operand is half the width of the vector
4 ; operands. We should get one ext instruction and not two.
7 define <8 x i8> @i8_off0(<16 x i8> %arg1, <16 x i8> %arg2) {
8 ; CHECK-LABEL: i8_off0:
13 %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>
17 define <8 x i8> @i8_off1(<16 x i8> %arg1, <16 x i8> %arg2) {
18 ; CHECK-LABEL: i8_off1:
20 ; CHECK: ext v0.16b, v0.16b, v0.16b, #1
24 %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>
28 define <8 x i8> @i8_off8(<16 x i8> %arg1, <16 x i8> %arg2) {
29 ; CHECK-LABEL: i8_off8:
31 ; CHECK: ext v0.16b, v0.16b, v0.16b, #8
35 %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>
39 define <8 x i8> @i8_off15(<16 x i8> %arg1, <16 x i8> %arg2) {
40 ; CHECK-LABEL: i8_off15:
41 ; CHECK: ext v0.16b, v0.16b, v1.16b, #15
45 %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>
49 define <8 x i8> @i8_off22(<16 x i8> %arg1, <16 x i8> %arg2) {
50 ; CHECK-LABEL: i8_off22:
51 ; CHECK: ext v0.16b, v1.16b, v1.16b, #6
55 %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>
60 define <4 x i16> @i16_off0(<8 x i16> %arg1, <8 x i16> %arg2) {
61 ; CHECK-LABEL: i16_off0:
66 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
67 ret <4 x i16> %shuffle
70 define <4 x i16> @i16_off1(<8 x i16> %arg1, <8 x i16> %arg2) {
71 ; CHECK-LABEL: i16_off1:
73 ; CHECK: ext v0.16b, v0.16b, v0.16b, #2
77 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
78 ret <4 x i16> %shuffle
81 define <4 x i16> @i16_off7(<8 x i16> %arg1, <8 x i16> %arg2) {
82 ; CHECK-LABEL: i16_off7:
83 ; CHECK: ext v0.16b, v0.16b, v1.16b, #14
87 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 7, i32 8, i32 9, i32 10>
88 ret <4 x i16> %shuffle
91 define <4 x i16> @i16_off8(<8 x i16> %arg1, <8 x i16> %arg2) {
92 ; CHECK-LABEL: i16_off8:
93 ; CHECK: mov v0.16b, v1.16b
97 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> %arg2, <4 x i32> <i32 8, i32 9, i32 10, i32 11>
98 ret <4 x i16> %shuffle
102 define <2 x i32> @i32_off0(<4 x i32> %arg1, <4 x i32> %arg2) {
103 ; CHECK-LABEL: i32_off0:
108 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 0, i32 1>
109 ret <2 x i32> %shuffle
112 define <2 x i32> @i32_off1(<4 x i32> %arg1, <4 x i32> %arg2) {
113 ; CHECK-LABEL: i32_off1:
115 ; CHECK: ext v0.16b, v0.16b, v0.16b, #4
119 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 1, i32 2>
120 ret <2 x i32> %shuffle
123 define <2 x i32> @i32_off3(<4 x i32> %arg1, <4 x i32> %arg2) {
124 ; CHECK-LABEL: i32_off3:
125 ; CHECK: ext v0.16b, v0.16b, v1.16b, #12
129 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 3, i32 4>
130 ret <2 x i32> %shuffle
133 define <2 x i32> @i32_off4(<4 x i32> %arg1, <4 x i32> %arg2) {
134 ; CHECK-LABEL: i32_off4:
135 ; CHECK: mov v0.16b, v1.16b
139 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> %arg2, <2 x i32> <i32 4, i32 5>
140 ret <2 x i32> %shuffle
144 define <1 x i64> @i64_off0(<2 x i64> %arg1, <2 x i64> %arg2) {
145 ; CHECK-LABEL: i64_off0:
150 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> %arg2, <1 x i32> <i32 0>
151 ret <1 x i64> %shuffle
154 define <1 x i64> @i64_off1(<2 x i64> %arg1, <2 x i64> %arg2) {
155 ; CHECK-LABEL: i64_off1:
157 ; CHECK: ext v0.16b, v0.16b, v0.16b, #8
161 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> %arg2, <1 x i32> <i32 1>
162 ret <1 x i64> %shuffle
165 define <1 x i64> @i64_off2(<2 x i64> %arg1, <2 x i64> %arg2) {
166 ; CHECK-LABEL: i64_off2:
167 ; CHECK: mov v0.16b, v1.16b
171 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> %arg2, <1 x i32> <i32 2>
172 ret <1 x i64> %shuffle
175 ; i8 tests with second operand zero
176 define <8 x i8> @i8_zero_off0(<16 x i8> %arg1) {
177 ; CHECK-LABEL: i8_zero_off0:
182 %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>
183 ret <8 x i8> %shuffle
186 define <8 x i8> @i8_zero_off1(<16 x i8> %arg1) {
187 ; CHECK-LABEL: i8_zero_off1:
189 ; CHECK: ext v0.16b, v0.16b, v0.16b, #1
193 %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>
194 ret <8 x i8> %shuffle
197 define <8 x i8> @i8_zero_off8(<16 x i8> %arg1) {
198 ; CHECK-LABEL: i8_zero_off8:
200 ; CHECK: ext v0.16b, v0.16b, v0.16b, #8
204 %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>
205 ret <8 x i8> %shuffle
208 define <8 x i8> @i8_zero_off15(<16 x i8> %arg1) {
209 ; CHECK-LABEL: i8_zero_off15:
210 ; CHECK: movi [[REG:v[0-9]+]].2d, #0
211 ; CHECK: ext v0.16b, v0.16b, [[REG]].16b, #15
215 %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>
216 ret <8 x i8> %shuffle
219 define <8 x i8> @i8_zero_off22(<16 x i8> %arg1) {
220 ; CHECK-LABEL: i8_zero_off22:
221 ; CHECK: movi v0.2d, #0
225 %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>
226 ret <8 x i8> %shuffle
229 ; i16 tests with second operand zero
230 define <4 x i16> @i16_zero_off0(<8 x i16> %arg1) {
231 ; CHECK-LABEL: i16_zero_off0:
236 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
237 ret <4 x i16> %shuffle
240 define <4 x i16> @i16_zero_off1(<8 x i16> %arg1) {
241 ; CHECK-LABEL: i16_zero_off1:
243 ; CHECK: ext v0.16b, v0.16b, v0.16b, #2
247 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
248 ret <4 x i16> %shuffle
251 define <4 x i16> @i16_zero_off7(<8 x i16> %arg1) {
252 ; CHECK-LABEL: i16_zero_off7:
253 ; CHECK: movi [[REG:v[0-9]+]].2d, #0
254 ; CHECK: ext v0.16b, v0.16b, [[REG]].16b, #14
258 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 7, i32 8, i32 9, i32 10>
259 ret <4 x i16> %shuffle
262 define <4 x i16> @i16_zero_off8(<8 x i16> %arg1) {
263 ; CHECK-LABEL: i16_zero_off8:
264 ; CHECK: movi v0.2d, #0
268 %shuffle = shufflevector <8 x i16> %arg1, <8 x i16> zeroinitializer, <4 x i32> <i32 8, i32 9, i32 10, i32 11>
269 ret <4 x i16> %shuffle
272 ; i32 tests with second operand zero
273 define <2 x i32> @i32_zero_off0(<4 x i32> %arg1) {
274 ; CHECK-LABEL: i32_zero_off0:
279 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 0, i32 1>
280 ret <2 x i32> %shuffle
283 define <2 x i32> @i32_zero_off1(<4 x i32> %arg1) {
284 ; CHECK-LABEL: i32_zero_off1:
286 ; CHECK: ext v0.16b, v0.16b, v0.16b, #4
290 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 1, i32 2>
291 ret <2 x i32> %shuffle
294 define <2 x i32> @i32_zero_off3(<4 x i32> %arg1) {
295 ; CHECK-LABEL: i32_zero_off3:
296 ; CHECK: movi [[REG:v[0-9]+]].2d, #0
297 ; CHECK: ext v0.16b, v0.16b, [[REG]].16b, #12
301 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 3, i32 4>
302 ret <2 x i32> %shuffle
305 define <2 x i32> @i32_zero_off4(<4 x i32> %arg1) {
306 ; CHECK-LABEL: i32_zero_off4:
307 ; CHECK: movi v0.2d, #0
311 %shuffle = shufflevector <4 x i32> %arg1, <4 x i32> zeroinitializer, <2 x i32> <i32 4, i32 5>
312 ret <2 x i32> %shuffle
315 ; i64 tests with second operand zero
316 define <1 x i64> @i64_zero_off0(<2 x i64> %arg1) {
317 ; CHECK-LABEL: i64_zero_off0:
322 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> zeroinitializer, <1 x i32> <i32 0>
323 ret <1 x i64> %shuffle
326 define <1 x i64> @i64_zero_off1(<2 x i64> %arg1) {
327 ; CHECK-LABEL: i64_zero_off1:
329 ; CHECK: ext v0.16b, v0.16b, v0.16b, #8
333 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> zeroinitializer, <1 x i32> <i32 1>
334 ret <1 x i64> %shuffle
337 define <1 x i64> @i64_zero_off2(<2 x i64> %arg1) {
338 ; CHECK-LABEL: i64_zero_off2:
339 ; CHECK: fmov d0, xzr
343 %shuffle = shufflevector <2 x i64> %arg1, <2 x i64> zeroinitializer, <1 x i32> <i32 2>
344 ret <1 x i64> %shuffle