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 4 x i64> @stepvector_nxv4i64() {
49 ; CHECK-LABEL: stepvector_nxv4i64:
50 ; CHECK: // %bb.0: // %entry
52 ; CHECK-NEXT: mov z1.d, x8
53 ; CHECK-NEXT: index z0.d, #0, #1
54 ; CHECK-NEXT: add z1.d, z0.d, z1.d
57 %0 = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
58 ret <vscale x 4 x i64> %0
61 define <vscale x 16 x i32> @stepvector_nxv16i32() {
62 ; CHECK-LABEL: stepvector_nxv16i32:
63 ; CHECK: // %bb.0: // %entry
66 ; CHECK-NEXT: index z0.s, #0, #1
67 ; CHECK-NEXT: mov z1.s, w9
68 ; CHECK-NEXT: mov z3.s, w8
69 ; CHECK-NEXT: add z1.s, z0.s, z1.s
70 ; CHECK-NEXT: add z2.s, z0.s, z3.s
71 ; CHECK-NEXT: add z3.s, z1.s, z3.s
74 %0 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
75 ret <vscale x 16 x i32> %0
78 define <vscale x 2 x i32> @stepvector_nxv2i32() {
79 ; CHECK-LABEL: stepvector_nxv2i32:
80 ; CHECK: // %bb.0: // %entry
81 ; CHECK-NEXT: index z0.d, #0, #1
84 %0 = call <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
85 ret <vscale x 2 x i32> %0
88 define <vscale x 4 x i16> @stepvector_nxv4i16() {
89 ; CHECK-LABEL: stepvector_nxv4i16:
90 ; CHECK: // %bb.0: // %entry
91 ; CHECK-NEXT: index z0.s, #0, #1
94 %0 = call <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()
95 ret <vscale x 4 x i16> %0
98 define <vscale x 8 x i8> @stepvector_nxv8i8() {
99 ; CHECK-LABEL: stepvector_nxv8i8:
100 ; CHECK: // %bb.0: // %entry
101 ; CHECK-NEXT: index z0.h, #0, #1
104 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
105 ret <vscale x 8 x i8> %0
108 define <vscale x 8 x i8> @add_stepvector_nxv8i8() {
109 ; CHECK-LABEL: add_stepvector_nxv8i8:
110 ; CHECK: // %bb.0: // %entry
111 ; CHECK-NEXT: index z0.h, #0, #2
114 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
115 %1 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
116 %2 = add <vscale x 8 x i8> %0, %1
117 ret <vscale x 8 x i8> %2
120 define <vscale x 8 x i8> @add_stepvector_nxv8i8_1(<vscale x 8 x i8> %p) {
121 ; CHECK-LABEL: add_stepvector_nxv8i8_1:
122 ; CHECK: // %bb.0: // %entry
123 ; CHECK-NEXT: index z1.h, #0, #2
124 ; CHECK-NEXT: add z0.h, z0.h, z1.h
127 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
128 %1 = add <vscale x 8 x i8> %p, %0
129 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
130 %3 = add <vscale x 8 x i8> %1, %2
131 ret <vscale x 8 x i8> %3
134 define <vscale x 8 x i8> @add_stepvector_nxv8i8_2() {
135 ; CHECK-LABEL: add_stepvector_nxv8i8_2:
136 ; CHECK: // %bb.0: // %entry
137 ; CHECK-NEXT: index z0.h, #2, #1
140 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
141 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
142 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
143 %3 = add <vscale x 8 x i8> %2, %1
144 ret <vscale x 8 x i8> %3
147 define <vscale x 8 x i8> @add_stepvector_nxv8i8_2_commutative() {
148 ; CHECK-LABEL: add_stepvector_nxv8i8_2_commutative:
149 ; CHECK: // %bb.0: // %entry
150 ; CHECK-NEXT: index z0.h, #2, #1
153 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
154 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
155 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
156 %3 = add <vscale x 8 x i8> %1, %2
157 ret <vscale x 8 x i8> %3
160 define <vscale x 8 x i16> @add_stepvector_nxv8i16_1(i16 %data) {
161 ; CHECK-LABEL: add_stepvector_nxv8i16_1:
162 ; CHECK: // %bb.0: // %entry
163 ; CHECK-NEXT: index z0.h, w0, #1
166 %0 = insertelement <vscale x 8 x i16> poison, i16 %data, i32 0
167 %1 = shufflevector <vscale x 8 x i16> %0, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
168 %2 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
169 %3 = add <vscale x 8 x i16> %2, %1
170 ret <vscale x 8 x i16> %3
173 define <vscale x 4 x i32> @add_stepvector_nxv4i32_1(i32 %data) {
174 ; CHECK-LABEL: add_stepvector_nxv4i32_1:
175 ; CHECK: // %bb.0: // %entry
176 ; CHECK-NEXT: index z0.s, w0, #1
179 %0 = insertelement <vscale x 4 x i32> poison, i32 %data, i32 0
180 %1 = shufflevector <vscale x 4 x i32> %0, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
181 %2 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
182 %3 = add <vscale x 4 x i32> %2, %1
183 ret <vscale x 4 x i32> %3
186 define <vscale x 4 x i32> @multiple_use_stepvector_nxv4i32_1(i32 %data) {
187 ; CHECK-LABEL: multiple_use_stepvector_nxv4i32_1:
188 ; CHECK: // %bb.0: // %entry
189 ; CHECK-NEXT: mov z0.s, w0
190 ; CHECK-NEXT: index z1.s, w0, #1
191 ; CHECK-NEXT: ptrue p0.s
192 ; CHECK-NEXT: mul z0.s, p0/m, z0.s, z1.s
193 ; CHECK-NEXT: sub z0.s, z0.s, z1.s
196 %0 = insertelement <vscale x 4 x i32> poison, i32 %data, i32 0
197 %1 = shufflevector <vscale x 4 x i32> %0, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
198 %2 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
199 %3 = add <vscale x 4 x i32> %2, %1
200 %4 = mul <vscale x 4 x i32> %1, %3
201 %5 = sub <vscale x 4 x i32> %4, %3
202 ret <vscale x 4 x i32> %5
205 define <vscale x 2 x i64> @add_stepvector_nxv2i64_1(i64 %data) {
206 ; CHECK-LABEL: add_stepvector_nxv2i64_1:
207 ; CHECK: // %bb.0: // %entry
208 ; CHECK-NEXT: index z0.d, x0, #1
211 %0 = insertelement <vscale x 2 x i64> poison, i64 %data, i32 0
212 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
213 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
214 %3 = add <vscale x 2 x i64> %1, %2
215 ret <vscale x 2 x i64> %3
218 define <vscale x 2 x i64> @multiple_use_stepvector_nxv2i64_1(i64 %data) {
219 ; CHECK-LABEL: multiple_use_stepvector_nxv2i64_1:
220 ; CHECK: // %bb.0: // %entry
221 ; CHECK-NEXT: mov z0.d, x0
222 ; CHECK-NEXT: index z1.d, #0, #1
223 ; CHECK-NEXT: add z0.d, z0.d, z1.d
224 ; CHECK-NEXT: ptrue p0.d
225 ; CHECK-NEXT: mul z0.d, p0/m, z0.d, z1.d
228 %0 = insertelement <vscale x 2 x i64> poison, i64 %data, i32 0
229 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
230 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
231 %3 = add <vscale x 2 x i64> %1, %2
232 %4 = mul <vscale x 2 x i64> %3, %2
233 ret <vscale x 2 x i64> %4
236 define <vscale x 8 x i8> @mul_stepvector_nxv8i8() {
237 ; CHECK-LABEL: mul_stepvector_nxv8i8:
238 ; CHECK: // %bb.0: // %entry
239 ; CHECK-NEXT: index z0.h, #0, #2
242 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
243 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
244 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
245 %3 = mul <vscale x 8 x i8> %2, %1
246 ret <vscale x 8 x i8> %3
249 define <vscale x 2 x i64> @mul_stepvector_nxv2i64() {
250 ; CHECK-LABEL: mul_stepvector_nxv2i64:
251 ; CHECK: // %bb.0: // %entry
252 ; CHECK-NEXT: mov w8, #2222
253 ; CHECK-NEXT: index z0.d, #0, x8
256 %0 = insertelement <vscale x 2 x i64> poison, i64 2222, i32 0
257 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
258 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
259 %3 = mul <vscale x 2 x i64> %2, %1
260 ret <vscale x 2 x i64> %3
263 define <vscale x 2 x i64> @mul_stepvector_bigconst_nxv2i64() {
264 ; CHECK-LABEL: mul_stepvector_bigconst_nxv2i64:
265 ; CHECK: // %bb.0: // %entry
266 ; CHECK-NEXT: mov x8, #146028888064
267 ; CHECK-NEXT: index z0.d, #0, x8
270 %0 = insertelement <vscale x 2 x i64> poison, i64 146028888064, i32 0
271 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
272 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
273 %3 = mul <vscale x 2 x i64> %2, %1
274 ret <vscale x 2 x i64> %3
277 define <vscale x 2 x i64> @mul_add_stepvector_nxv2i64(i64 %x) {
278 ; CHECK-LABEL: mul_add_stepvector_nxv2i64:
279 ; CHECK: // %bb.0: // %entry
280 ; CHECK-NEXT: mov w8, #2222
281 ; CHECK-NEXT: index z0.d, x0, x8
284 %0 = insertelement <vscale x 2 x i64> poison, i64 2222, i32 0
285 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
286 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
287 %3 = mul <vscale x 2 x i64> %2, %1
288 %4 = insertelement <vscale x 2 x i64> poison, i64 %x, i32 0
289 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
290 %6 = add <vscale x 2 x i64> %3, %5
291 ret <vscale x 2 x i64> %6
294 define <vscale x 2 x i64> @mul_add_stepvector_bigconst_nxv2i64(i64 %x) {
295 ; CHECK-LABEL: mul_add_stepvector_bigconst_nxv2i64:
296 ; CHECK: // %bb.0: // %entry
297 ; CHECK-NEXT: mov x8, #146028888064
298 ; CHECK-NEXT: index z0.d, x0, x8
301 %0 = insertelement <vscale x 2 x i64> poison, i64 146028888064, i32 0
302 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
303 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
304 %3 = mul <vscale x 2 x i64> %2, %1
305 %4 = insertelement <vscale x 2 x i64> poison, i64 %x, i32 0
306 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
307 %6 = add <vscale x 2 x i64> %3, %5
308 ret <vscale x 2 x i64> %6
311 define <vscale x 2 x i64> @mul_mul_add_stepvector_nxv2i64(i64 %x, i64 %y) {
312 ; CHECK-LABEL: mul_mul_add_stepvector_nxv2i64:
313 ; CHECK: // %bb.0: // %entry
314 ; CHECK-NEXT: add x8, x0, x0, lsl #1
315 ; CHECK-NEXT: index z0.d, x1, x8
318 %xmul = mul i64 %x, 3
319 %0 = insertelement <vscale x 2 x i64> poison, i64 %xmul, i32 0
320 %1 = shufflevector <vscale x 2 x i64> %0, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
321 %2 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
322 %3 = mul <vscale x 2 x i64> %2, %1
323 %4 = insertelement <vscale x 2 x i64> poison, i64 %y, i32 0
324 %5 = shufflevector <vscale x 2 x i64> %4, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
325 %6 = add <vscale x 2 x i64> %3, %5
326 ret <vscale x 2 x i64> %6
329 define <vscale x 8 x i8> @shl_stepvector_nxv8i8() {
330 ; CHECK-LABEL: shl_stepvector_nxv8i8:
331 ; CHECK: // %bb.0: // %entry
332 ; CHECK-NEXT: index z0.h, #0, #4
335 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
336 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
337 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
338 %3 = shl <vscale x 8 x i8> %2, %1
339 ret <vscale x 8 x i8> %3
342 define <vscale x 8 x i16> @sub_multiple_use_stepvector_nxv8i16() {
343 ; CHECK-LABEL: sub_multiple_use_stepvector_nxv8i16:
344 ; CHECK: // %bb.0: // %entry
345 ; CHECK-NEXT: index z0.h, #0, #1
346 ; CHECK-NEXT: mov z1.d, z0.d
347 ; CHECK-NEXT: subr z1.h, z1.h, #2 // =0x2
348 ; CHECK-NEXT: ptrue p0.h
349 ; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h
352 %0 = insertelement <vscale x 8 x i16> poison, i16 2, i32 0
353 %1 = shufflevector <vscale x 8 x i16> %0, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
354 %2 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
355 %3 = sub <vscale x 8 x i16> %1, %2
356 %4 = shl <vscale x 8 x i16> %2, %3
357 ret <vscale x 8 x i16> %4
360 define <vscale x 8 x i16> @sub_stepvector_nxv8i16() {
361 ; CHECK-LABEL: sub_stepvector_nxv8i16:
362 ; CHECK: // %bb.0: // %entry
363 ; CHECK-NEXT: index z0.h, #2, #-1
366 %0 = insertelement <vscale x 8 x i16> poison, i16 2, i32 0
367 %1 = shufflevector <vscale x 8 x i16> %0, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
368 %2 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
369 %3 = sub <vscale x 8 x i16> %1, %2
370 ret <vscale x 8 x i16> %3
373 define <vscale x 8 x i8> @promote_sub_stepvector_nxv8i8() {
374 ; CHECK-LABEL: promote_sub_stepvector_nxv8i8:
375 ; CHECK: // %bb.0: // %entry
376 ; CHECK-NEXT: index z0.h, #2, #-1
379 %0 = insertelement <vscale x 8 x i8> poison, i8 2, i32 0
380 %1 = shufflevector <vscale x 8 x i8> %0, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
381 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
382 %3 = sub <vscale x 8 x i8> %1, %2
383 ret <vscale x 8 x i8> %3
386 define <vscale x 16 x i32> @split_sub_stepvector_nxv16i32() {
387 ; CHECK-LABEL: split_sub_stepvector_nxv16i32:
388 ; CHECK: // %bb.0: // %entry
389 ; CHECK-NEXT: cntw x9
390 ; CHECK-NEXT: cnth x8
391 ; CHECK-NEXT: neg x9, x9
392 ; CHECK-NEXT: index z0.s, #0, #-1
393 ; CHECK-NEXT: neg x8, x8
394 ; CHECK-NEXT: mov z1.s, w9
395 ; CHECK-NEXT: mov z3.s, w8
396 ; CHECK-NEXT: add z1.s, z0.s, z1.s
397 ; CHECK-NEXT: add z2.s, z0.s, z3.s
398 ; CHECK-NEXT: add z3.s, z1.s, z3.s
401 %0 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
402 %1 = sub <vscale x 16 x i32> zeroinitializer, %0
403 ret <vscale x 16 x i32> %1
406 declare <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
407 declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
408 declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
409 declare <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
411 declare <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
412 declare <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
413 declare <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
414 declare <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
415 declare <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()