1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s --check-prefixes=CHECK
6 define <vscale x 2 x i64> @stepvector_nxv2i64() {
7 ; CHECK-LABEL: stepvector_nxv2i64:
8 ; CHECK: // %bb.0: // %entry
9 ; CHECK-NEXT: index z0.d, #0, #1
12 %0 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
13 ret <vscale x 2 x i64> %0
16 define <vscale x 4 x i32> @stepvector_nxv4i32() {
17 ; CHECK-LABEL: stepvector_nxv4i32:
18 ; CHECK: // %bb.0: // %entry
19 ; CHECK-NEXT: index z0.s, #0, #1
22 %0 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
23 ret <vscale x 4 x i32> %0
26 define <vscale x 8 x i16> @stepvector_nxv8i16() {
27 ; CHECK-LABEL: stepvector_nxv8i16:
28 ; CHECK: // %bb.0: // %entry
29 ; CHECK-NEXT: index z0.h, #0, #1
32 %0 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
33 ret <vscale x 8 x i16> %0
36 define <vscale x 16 x i8> @stepvector_nxv16i8() {
37 ; CHECK-LABEL: stepvector_nxv16i8:
38 ; CHECK: // %bb.0: // %entry
39 ; CHECK-NEXT: index z0.b, #0, #1
42 %0 = call <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
43 ret <vscale x 16 x i8> %0
46 ; ILLEGAL INTEGER TYPES
48 define <vscale x 6 x i64> @stepvector_nxv6i64() {
49 ; CHECK-LABEL: stepvector_nxv6i64:
50 ; CHECK: // %bb.0: // %entry
51 ; CHECK-NEXT: index z0.d, #0, #1
52 ; CHECK-NEXT: mov z2.d, z0.d
53 ; CHECK-NEXT: mov z1.d, z0.d
54 ; CHECK-NEXT: incd z1.d
55 ; CHECK-NEXT: incd z2.d, all, mul #2
58 %0 = call <vscale x 6 x i64> @llvm.experimental.stepvector.nxv6i64()
59 ret <vscale x 6 x i64> %0
62 define <vscale x 4 x i64> @stepvector_nxv4i64() {
63 ; CHECK-LABEL: stepvector_nxv4i64:
64 ; CHECK: // %bb.0: // %entry
65 ; CHECK-NEXT: index z0.d, #0, #1
66 ; CHECK-NEXT: mov z1.d, z0.d
67 ; CHECK-NEXT: incd z1.d
70 %0 = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
71 ret <vscale x 4 x i64> %0
74 define <vscale x 16 x i32> @stepvector_nxv16i32() {
75 ; CHECK-LABEL: stepvector_nxv16i32:
76 ; CHECK: // %bb.0: // %entry
77 ; CHECK-NEXT: index z0.s, #0, #1
78 ; CHECK-NEXT: mov z1.d, z0.d
79 ; CHECK-NEXT: mov z2.d, z0.d
80 ; CHECK-NEXT: incw z1.s
81 ; CHECK-NEXT: incw z2.s, all, mul #2
82 ; CHECK-NEXT: mov z3.d, z1.d
83 ; CHECK-NEXT: incw z3.s, all, mul #2
86 %0 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
87 ret <vscale x 16 x i32> %0
90 define <vscale x 3 x i32> @stepvector_nxv3i32() {
91 ; CHECK-LABEL: stepvector_nxv3i32:
92 ; CHECK: // %bb.0: // %entry
93 ; CHECK-NEXT: index z0.s, #0, #1
96 %0 = call <vscale x 3 x i32> @llvm.experimental.stepvector.nxv3i32()
97 ret <vscale x 3 x i32> %0
100 define <vscale x 2 x i32> @stepvector_nxv2i32() {
101 ; CHECK-LABEL: stepvector_nxv2i32:
102 ; CHECK: // %bb.0: // %entry
103 ; CHECK-NEXT: index z0.d, #0, #1
106 %0 = call <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
107 ret <vscale x 2 x i32> %0
110 define <vscale x 4 x i16> @stepvector_nxv4i16() {
111 ; CHECK-LABEL: stepvector_nxv4i16:
112 ; CHECK: // %bb.0: // %entry
113 ; CHECK-NEXT: index z0.s, #0, #1
116 %0 = call <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()
117 ret <vscale x 4 x i16> %0
120 define <vscale x 8 x i8> @stepvector_nxv8i8() {
121 ; CHECK-LABEL: stepvector_nxv8i8:
122 ; CHECK: // %bb.0: // %entry
123 ; CHECK-NEXT: index z0.h, #0, #1
126 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
127 ret <vscale x 8 x i8> %0
130 define <vscale x 8 x i8> @add_stepvector_nxv8i8() {
131 ; CHECK-LABEL: add_stepvector_nxv8i8:
132 ; CHECK: // %bb.0: // %entry
133 ; CHECK-NEXT: index z0.h, #0, #2
136 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
137 %1 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
138 %2 = add <vscale x 8 x i8> %0, %1
139 ret <vscale x 8 x i8> %2
142 define <vscale x 8 x i8> @add_stepvector_nxv8i8_1(<vscale x 8 x i8> %p) {
143 ; CHECK-LABEL: add_stepvector_nxv8i8_1:
144 ; CHECK: // %bb.0: // %entry
145 ; CHECK-NEXT: index z1.h, #0, #2
146 ; CHECK-NEXT: add z0.h, z0.h, z1.h
149 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
150 %1 = add <vscale x 8 x i8> %p, %0
151 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
152 %3 = add <vscale x 8 x i8> %1, %2
153 ret <vscale x 8 x i8> %3
156 define <vscale x 8 x i8> @add_stepvector_nxv8i8_2() {
157 ; CHECK-LABEL: add_stepvector_nxv8i8_2:
158 ; CHECK: // %bb.0: // %entry
159 ; CHECK-NEXT: index z0.h, #2, #1
162 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
163 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
164 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
165 %3 = add <vscale x 8 x i8> %2, %1
166 ret <vscale x 8 x i8> %3
169 define <vscale x 8 x i8> @add_stepvector_nxv8i8_2_commutative() {
170 ; CHECK-LABEL: add_stepvector_nxv8i8_2_commutative:
171 ; CHECK: // %bb.0: // %entry
172 ; CHECK-NEXT: index z0.h, #2, #1
175 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
176 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
177 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
178 %3 = add <vscale x 8 x i8> %1, %2
179 ret <vscale x 8 x i8> %3
182 define <vscale x 8 x i16> @add_stepvector_nxv8i16_1(i16 %data) {
183 ; CHECK-LABEL: add_stepvector_nxv8i16_1:
184 ; CHECK: // %bb.0: // %entry
185 ; CHECK-NEXT: index z0.h, w0, #1
188 %0 = insertelement <vscale x 8 x i16> poison, i16 %data, i32 0
189 %1 = shufflevector <vscale x 8 x i16> %0, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
190 %2 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
191 %3 = add <vscale x 8 x i16> %2, %1
192 ret <vscale x 8 x i16> %3
195 define <vscale x 4 x i32> @add_stepvector_nxv4i32_1(i32 %data) {
196 ; CHECK-LABEL: add_stepvector_nxv4i32_1:
197 ; CHECK: // %bb.0: // %entry
198 ; CHECK-NEXT: index z0.s, w0, #1
201 %0 = insertelement <vscale x 4 x i32> poison, i32 %data, i32 0
202 %1 = shufflevector <vscale x 4 x i32> %0, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
203 %2 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
204 %3 = add <vscale x 4 x i32> %2, %1
205 ret <vscale x 4 x i32> %3
208 define <vscale x 4 x i32> @multiple_use_stepvector_nxv4i32_1(i32 %data) {
209 ; CHECK-LABEL: multiple_use_stepvector_nxv4i32_1:
210 ; CHECK: // %bb.0: // %entry
211 ; CHECK-NEXT: ptrue p0.s
212 ; CHECK-NEXT: index z0.s, w0, #1
213 ; CHECK-NEXT: mov z1.s, w0
214 ; CHECK-NEXT: mul z1.s, p0/m, z1.s, z0.s
215 ; CHECK-NEXT: sub z0.s, z1.s, z0.s
218 %0 = insertelement <vscale x 4 x i32> poison, i32 %data, i32 0
219 %1 = shufflevector <vscale x 4 x i32> %0, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
220 %2 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
221 %3 = add <vscale x 4 x i32> %2, %1
222 %4 = mul <vscale x 4 x i32> %1, %3
223 %5 = sub <vscale x 4 x i32> %4, %3
224 ret <vscale x 4 x i32> %5
227 define <vscale x 2 x i64> @add_stepvector_nxv2i64_1(i64 %data) {
228 ; CHECK-LABEL: add_stepvector_nxv2i64_1:
229 ; CHECK: // %bb.0: // %entry
230 ; CHECK-NEXT: index z0.d, x0, #1
233 %0 = insertelement <vscale x 2 x i64> poison, i64 %data, i32 0
234 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
235 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
236 %3 = add <vscale x 2 x i64> %1, %2
237 ret <vscale x 2 x i64> %3
240 define <vscale x 2 x i64> @multiple_use_stepvector_nxv2i64_1(i64 %data) {
241 ; CHECK-LABEL: multiple_use_stepvector_nxv2i64_1:
242 ; CHECK: // %bb.0: // %entry
243 ; CHECK-NEXT: index z0.d, #0, #1
244 ; CHECK-NEXT: mov z1.d, x0
245 ; CHECK-NEXT: ptrue p0.d
246 ; CHECK-NEXT: add z1.d, z0.d, z1.d
247 ; CHECK-NEXT: mul z0.d, p0/m, z0.d, z1.d
250 %0 = insertelement <vscale x 2 x i64> poison, i64 %data, i32 0
251 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
252 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
253 %3 = add <vscale x 2 x i64> %1, %2
254 %4 = mul <vscale x 2 x i64> %3, %2
255 ret <vscale x 2 x i64> %4
258 define <vscale x 8 x i8> @mul_stepvector_nxv8i8() {
259 ; CHECK-LABEL: mul_stepvector_nxv8i8:
260 ; CHECK: // %bb.0: // %entry
261 ; CHECK-NEXT: index z0.h, #0, #2
264 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
265 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
266 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
267 %3 = mul <vscale x 8 x i8> %2, %1
268 ret <vscale x 8 x i8> %3
271 define <vscale x 2 x i64> @mul_stepvector_nxv2i64() {
272 ; CHECK-LABEL: mul_stepvector_nxv2i64:
273 ; CHECK: // %bb.0: // %entry
274 ; CHECK-NEXT: mov w8, #2222 // =0x8ae
275 ; CHECK-NEXT: index z0.d, #0, x8
278 %0 = insertelement <vscale x 2 x i64> poison, i64 2222, i32 0
279 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
280 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
281 %3 = mul <vscale x 2 x i64> %2, %1
282 ret <vscale x 2 x i64> %3
285 define <vscale x 2 x i64> @mul_stepvector_bigconst_nxv2i64() {
286 ; CHECK-LABEL: mul_stepvector_bigconst_nxv2i64:
287 ; CHECK: // %bb.0: // %entry
288 ; CHECK-NEXT: mov x8, #146028888064 // =0x2200000000
289 ; CHECK-NEXT: index z0.d, #0, x8
292 %0 = insertelement <vscale x 2 x i64> poison, i64 146028888064, i32 0
293 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
294 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
295 %3 = mul <vscale x 2 x i64> %2, %1
296 ret <vscale x 2 x i64> %3
299 define <vscale x 2 x i64> @mul_add_stepvector_nxv2i64(i64 %x) {
300 ; CHECK-LABEL: mul_add_stepvector_nxv2i64:
301 ; CHECK: // %bb.0: // %entry
302 ; CHECK-NEXT: mov w8, #2222 // =0x8ae
303 ; CHECK-NEXT: index z0.d, x0, x8
306 %0 = insertelement <vscale x 2 x i64> poison, i64 2222, i32 0
307 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
308 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
309 %3 = mul <vscale x 2 x i64> %2, %1
310 %4 = insertelement <vscale x 2 x i64> poison, i64 %x, i32 0
311 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
312 %6 = add <vscale x 2 x i64> %3, %5
313 ret <vscale x 2 x i64> %6
316 define <vscale x 2 x i64> @mul_add_stepvector_nxv2i64_commutative(i64 %x, i64 %y) {
317 ; CHECK-LABEL: mul_add_stepvector_nxv2i64_commutative:
318 ; CHECK: // %bb.0: // %entry
319 ; CHECK-NEXT: index z0.d, x0, x1
322 %0 = insertelement <vscale x 2 x i64> poison, i64 %y, i32 0
323 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
324 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
325 %3 = mul <vscale x 2 x i64> %1, %2
326 %4 = insertelement <vscale x 2 x i64> poison, i64 %x, i32 0
327 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
328 %6 = add <vscale x 2 x i64> %5, %3
329 ret <vscale x 2 x i64> %6
332 define <vscale x 2 x i64> @mul_add_stepvector_bigconst_nxv2i64(i64 %x) {
333 ; CHECK-LABEL: mul_add_stepvector_bigconst_nxv2i64:
334 ; CHECK: // %bb.0: // %entry
335 ; CHECK-NEXT: mov x8, #146028888064 // =0x2200000000
336 ; CHECK-NEXT: index z0.d, x0, x8
339 %0 = insertelement <vscale x 2 x i64> poison, i64 146028888064, i32 0
340 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
341 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
342 %3 = mul <vscale x 2 x i64> %2, %1
343 %4 = insertelement <vscale x 2 x i64> poison, i64 %x, i32 0
344 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
345 %6 = add <vscale x 2 x i64> %3, %5
346 ret <vscale x 2 x i64> %6
349 define <vscale x 2 x i64> @mul_mul_add_stepvector_nxv2i64(i64 %x, i64 %y) {
350 ; CHECK-LABEL: mul_mul_add_stepvector_nxv2i64:
351 ; CHECK: // %bb.0: // %entry
352 ; CHECK-NEXT: add x8, x0, x0, lsl #1
353 ; CHECK-NEXT: index z0.d, x1, x8
356 %xmul = mul i64 %x, 3
357 %0 = insertelement <vscale x 2 x i64> poison, i64 %xmul, i32 0
358 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
359 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
360 %3 = mul <vscale x 2 x i64> %2, %1
361 %4 = insertelement <vscale x 2 x i64> poison, i64 %y, i32 0
362 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
363 %6 = add <vscale x 2 x i64> %3, %5
364 ret <vscale x 2 x i64> %6
367 define <vscale x 8 x i8> @shl_stepvector_nxv8i8() {
368 ; CHECK-LABEL: shl_stepvector_nxv8i8:
369 ; CHECK: // %bb.0: // %entry
370 ; CHECK-NEXT: index z0.h, #0, #4
373 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
374 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
375 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
376 %3 = shl <vscale x 8 x i8> %2, %1
377 ret <vscale x 8 x i8> %3
380 define <vscale x 8 x i16> @sub_multiple_use_stepvector_nxv8i16() {
381 ; CHECK-LABEL: sub_multiple_use_stepvector_nxv8i16:
382 ; CHECK: // %bb.0: // %entry
383 ; CHECK-NEXT: index z0.h, #0, #1
384 ; CHECK-NEXT: ptrue p0.h
385 ; CHECK-NEXT: mov z1.d, z0.d
386 ; CHECK-NEXT: subr z1.h, z1.h, #2 // =0x2
387 ; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h
390 %0 = insertelement <vscale x 8 x i16> poison, i16 2, i32 0
391 %1 = shufflevector <vscale x 8 x i16> %0, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
392 %2 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
393 %3 = sub <vscale x 8 x i16> %1, %2
394 %4 = shl <vscale x 8 x i16> %2, %3
395 ret <vscale x 8 x i16> %4
398 define <vscale x 8 x i16> @sub_stepvector_nxv8i16() {
399 ; CHECK-LABEL: sub_stepvector_nxv8i16:
400 ; CHECK: // %bb.0: // %entry
401 ; CHECK-NEXT: index z0.h, #2, #-1
404 %0 = insertelement <vscale x 8 x i16> poison, i16 2, i32 0
405 %1 = shufflevector <vscale x 8 x i16> %0, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
406 %2 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
407 %3 = sub <vscale x 8 x i16> %1, %2
408 ret <vscale x 8 x i16> %3
411 define <vscale x 8 x i8> @promote_sub_stepvector_nxv8i8() {
412 ; CHECK-LABEL: promote_sub_stepvector_nxv8i8:
413 ; CHECK: // %bb.0: // %entry
414 ; CHECK-NEXT: index z0.h, #2, #-1
417 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
418 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
419 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
420 %3 = sub <vscale x 8 x i8> %1, %2
421 ret <vscale x 8 x i8> %3
424 define <vscale x 16 x i32> @split_sub_stepvector_nxv16i32() {
425 ; CHECK-LABEL: split_sub_stepvector_nxv16i32:
426 ; CHECK: // %bb.0: // %entry
427 ; CHECK-NEXT: cntw x8
428 ; CHECK-NEXT: index z0.s, #0, #-1
429 ; CHECK-NEXT: neg x8, x8
430 ; CHECK-NEXT: mov z1.s, w8
431 ; CHECK-NEXT: cnth x8
432 ; CHECK-NEXT: neg x8, x8
433 ; CHECK-NEXT: mov z3.s, w8
434 ; CHECK-NEXT: add z1.s, z0.s, z1.s
435 ; CHECK-NEXT: add z2.s, z0.s, z3.s
436 ; CHECK-NEXT: add z3.s, z1.s, z3.s
439 %0 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
440 %1 = sub <vscale x 16 x i32> zeroinitializer, %0
441 ret <vscale x 16 x i32> %1
444 declare <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
445 declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
446 declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
447 declare <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
449 declare <vscale x 6 x i64> @llvm.experimental.stepvector.nxv6i64()
450 declare <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
451 declare <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
452 declare <vscale x 3 x i32> @llvm.experimental.stepvector.nxv3i32()
453 declare <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
454 declare <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
455 declare <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()