1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+m,+v -verify-machineinstrs < %s | FileCheck %s -check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+m,+v -verify-machineinstrs < %s | FileCheck %s -check-prefixes=CHECK,RV64
5 declare <vscale x 1 x i8> @llvm.experimental.stepvector.nxv1i8()
7 define <vscale x 1 x i8> @stepvector_nxv1i8() {
8 ; CHECK-LABEL: stepvector_nxv1i8:
10 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
11 ; CHECK-NEXT: vid.v v8
13 %v = call <vscale x 1 x i8> @llvm.experimental.stepvector.nxv1i8()
14 ret <vscale x 1 x i8> %v
17 declare <vscale x 2 x i8> @llvm.experimental.stepvector.nxv2i8()
19 define <vscale x 2 x i8> @stepvector_nxv2i8() {
20 ; CHECK-LABEL: stepvector_nxv2i8:
22 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
23 ; CHECK-NEXT: vid.v v8
25 %v = call <vscale x 2 x i8> @llvm.experimental.stepvector.nxv2i8()
26 ret <vscale x 2 x i8> %v
29 declare <vscale x 3 x i8> @llvm.experimental.stepvector.nxv3i8()
31 define <vscale x 3 x i8> @stepvector_nxv3i8() {
32 ; CHECK-LABEL: stepvector_nxv3i8:
34 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
35 ; CHECK-NEXT: vid.v v8
37 %v = call <vscale x 3 x i8> @llvm.experimental.stepvector.nxv3i8()
38 ret <vscale x 3 x i8> %v
41 declare <vscale x 4 x i8> @llvm.experimental.stepvector.nxv4i8()
43 define <vscale x 4 x i8> @stepvector_nxv4i8() {
44 ; CHECK-LABEL: stepvector_nxv4i8:
46 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
47 ; CHECK-NEXT: vid.v v8
49 %v = call <vscale x 4 x i8> @llvm.experimental.stepvector.nxv4i8()
50 ret <vscale x 4 x i8> %v
53 declare <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
55 define <vscale x 8 x i8> @stepvector_nxv8i8() {
56 ; CHECK-LABEL: stepvector_nxv8i8:
58 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
59 ; CHECK-NEXT: vid.v v8
61 %v = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
62 ret <vscale x 8 x i8> %v
65 define <vscale x 8 x i8> @add_stepvector_nxv8i8() {
66 ; CHECK-LABEL: add_stepvector_nxv8i8:
67 ; CHECK: # %bb.0: # %entry
68 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
69 ; CHECK-NEXT: vid.v v8
70 ; CHECK-NEXT: vadd.vv v8, v8, v8
73 %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
74 %1 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
75 %2 = add <vscale x 8 x i8> %0, %1
76 ret <vscale x 8 x i8> %2
79 define <vscale x 8 x i8> @mul_stepvector_nxv8i8() {
80 ; CHECK-LABEL: mul_stepvector_nxv8i8:
81 ; CHECK: # %bb.0: # %entry
82 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
83 ; CHECK-NEXT: vid.v v8
84 ; CHECK-NEXT: li a0, 3
85 ; CHECK-NEXT: vmul.vx v8, v8, a0
88 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
89 %3 = mul <vscale x 8 x i8> %2, splat (i8 3)
90 ret <vscale x 8 x i8> %3
93 define <vscale x 8 x i8> @shl_stepvector_nxv8i8() {
94 ; CHECK-LABEL: shl_stepvector_nxv8i8:
95 ; CHECK: # %bb.0: # %entry
96 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
97 ; CHECK-NEXT: vid.v v8
98 ; CHECK-NEXT: vsll.vi v8, v8, 2
101 %2 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
102 %3 = shl <vscale x 8 x i8> %2, splat (i8 2)
103 ret <vscale x 8 x i8> %3
106 declare <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
108 define <vscale x 16 x i8> @stepvector_nxv16i8() {
109 ; CHECK-LABEL: stepvector_nxv16i8:
111 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
112 ; CHECK-NEXT: vid.v v8
114 %v = call <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
115 ret <vscale x 16 x i8> %v
118 declare <vscale x 32 x i8> @llvm.experimental.stepvector.nxv32i8()
120 define <vscale x 32 x i8> @stepvector_nxv32i8() {
121 ; CHECK-LABEL: stepvector_nxv32i8:
123 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
124 ; CHECK-NEXT: vid.v v8
126 %v = call <vscale x 32 x i8> @llvm.experimental.stepvector.nxv32i8()
127 ret <vscale x 32 x i8> %v
130 declare <vscale x 64 x i8> @llvm.experimental.stepvector.nxv64i8()
132 define <vscale x 64 x i8> @stepvector_nxv64i8() {
133 ; CHECK-LABEL: stepvector_nxv64i8:
135 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
136 ; CHECK-NEXT: vid.v v8
138 %v = call <vscale x 64 x i8> @llvm.experimental.stepvector.nxv64i8()
139 ret <vscale x 64 x i8> %v
142 declare <vscale x 1 x i16> @llvm.experimental.stepvector.nxv1i16()
144 define <vscale x 1 x i16> @stepvector_nxv1i16() {
145 ; CHECK-LABEL: stepvector_nxv1i16:
147 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
148 ; CHECK-NEXT: vid.v v8
150 %v = call <vscale x 1 x i16> @llvm.experimental.stepvector.nxv1i16()
151 ret <vscale x 1 x i16> %v
154 declare <vscale x 2 x i16> @llvm.experimental.stepvector.nxv2i16()
156 define <vscale x 2 x i16> @stepvector_nxv2i16() {
157 ; CHECK-LABEL: stepvector_nxv2i16:
159 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
160 ; CHECK-NEXT: vid.v v8
162 %v = call <vscale x 2 x i16> @llvm.experimental.stepvector.nxv2i16()
163 ret <vscale x 2 x i16> %v
166 declare <vscale x 2 x i15> @llvm.experimental.stepvector.nxv2i15()
168 define <vscale x 2 x i15> @stepvector_nxv2i15() {
169 ; CHECK-LABEL: stepvector_nxv2i15:
171 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
172 ; CHECK-NEXT: vid.v v8
174 %v = call <vscale x 2 x i15> @llvm.experimental.stepvector.nxv2i15()
175 ret <vscale x 2 x i15> %v
178 declare <vscale x 3 x i16> @llvm.experimental.stepvector.nxv3i16()
180 define <vscale x 3 x i16> @stepvector_nxv3i16() {
181 ; CHECK-LABEL: stepvector_nxv3i16:
183 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
184 ; CHECK-NEXT: vid.v v8
186 %v = call <vscale x 3 x i16> @llvm.experimental.stepvector.nxv3i16()
187 ret <vscale x 3 x i16> %v
190 declare <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()
192 define <vscale x 4 x i16> @stepvector_nxv4i16() {
193 ; CHECK-LABEL: stepvector_nxv4i16:
195 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
196 ; CHECK-NEXT: vid.v v8
198 %v = call <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()
199 ret <vscale x 4 x i16> %v
202 declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
204 define <vscale x 8 x i16> @stepvector_nxv8i16() {
205 ; CHECK-LABEL: stepvector_nxv8i16:
207 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
208 ; CHECK-NEXT: vid.v v8
210 %v = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
211 ret <vscale x 8 x i16> %v
214 declare <vscale x 16 x i16> @llvm.experimental.stepvector.nxv16i16()
216 define <vscale x 16 x i16> @stepvector_nxv16i16() {
217 ; CHECK-LABEL: stepvector_nxv16i16:
219 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
220 ; CHECK-NEXT: vid.v v8
222 %v = call <vscale x 16 x i16> @llvm.experimental.stepvector.nxv16i16()
223 ret <vscale x 16 x i16> %v
226 define <vscale x 16 x i16> @add_stepvector_nxv16i16() {
227 ; CHECK-LABEL: add_stepvector_nxv16i16:
228 ; CHECK: # %bb.0: # %entry
229 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
230 ; CHECK-NEXT: vid.v v8
231 ; CHECK-NEXT: vadd.vv v8, v8, v8
234 %0 = call <vscale x 16 x i16> @llvm.experimental.stepvector.nxv16i16()
235 %1 = call <vscale x 16 x i16> @llvm.experimental.stepvector.nxv16i16()
236 %2 = add <vscale x 16 x i16> %0, %1
237 ret <vscale x 16 x i16> %2
240 define <vscale x 16 x i16> @mul_stepvector_nxv16i16() {
241 ; CHECK-LABEL: mul_stepvector_nxv16i16:
242 ; CHECK: # %bb.0: # %entry
243 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
244 ; CHECK-NEXT: vid.v v8
245 ; CHECK-NEXT: li a0, 3
246 ; CHECK-NEXT: vmul.vx v8, v8, a0
249 %2 = call <vscale x 16 x i16> @llvm.experimental.stepvector.nxv16i16()
250 %3 = mul <vscale x 16 x i16> %2, splat (i16 3)
251 ret <vscale x 16 x i16> %3
254 define <vscale x 16 x i16> @shl_stepvector_nxv16i16() {
255 ; CHECK-LABEL: shl_stepvector_nxv16i16:
256 ; CHECK: # %bb.0: # %entry
257 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
258 ; CHECK-NEXT: vid.v v8
259 ; CHECK-NEXT: vsll.vi v8, v8, 2
262 %2 = call <vscale x 16 x i16> @llvm.experimental.stepvector.nxv16i16()
263 %3 = shl <vscale x 16 x i16> %2, splat (i16 2)
264 ret <vscale x 16 x i16> %3
267 declare <vscale x 32 x i16> @llvm.experimental.stepvector.nxv32i16()
269 define <vscale x 32 x i16> @stepvector_nxv32i16() {
270 ; CHECK-LABEL: stepvector_nxv32i16:
272 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
273 ; CHECK-NEXT: vid.v v8
275 %v = call <vscale x 32 x i16> @llvm.experimental.stepvector.nxv32i16()
276 ret <vscale x 32 x i16> %v
279 declare <vscale x 1 x i32> @llvm.experimental.stepvector.nxv1i32()
281 define <vscale x 1 x i32> @stepvector_nxv1i32() {
282 ; CHECK-LABEL: stepvector_nxv1i32:
284 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
285 ; CHECK-NEXT: vid.v v8
287 %v = call <vscale x 1 x i32> @llvm.experimental.stepvector.nxv1i32()
288 ret <vscale x 1 x i32> %v
291 declare <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
293 define <vscale x 2 x i32> @stepvector_nxv2i32() {
294 ; CHECK-LABEL: stepvector_nxv2i32:
296 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
297 ; CHECK-NEXT: vid.v v8
299 %v = call <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
300 ret <vscale x 2 x i32> %v
303 declare <vscale x 3 x i32> @llvm.experimental.stepvector.nxv3i32()
305 define <vscale x 3 x i32> @stepvector_nxv3i32() {
306 ; CHECK-LABEL: stepvector_nxv3i32:
308 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
309 ; CHECK-NEXT: vid.v v8
311 %v = call <vscale x 3 x i32> @llvm.experimental.stepvector.nxv3i32()
312 ret <vscale x 3 x i32> %v
315 declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
317 define <vscale x 4 x i32> @stepvector_nxv4i32() {
318 ; CHECK-LABEL: stepvector_nxv4i32:
320 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
321 ; CHECK-NEXT: vid.v v8
323 %v = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
324 ret <vscale x 4 x i32> %v
327 declare <vscale x 8 x i32> @llvm.experimental.stepvector.nxv8i32()
329 define <vscale x 8 x i32> @stepvector_nxv8i32() {
330 ; CHECK-LABEL: stepvector_nxv8i32:
332 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
333 ; CHECK-NEXT: vid.v v8
335 %v = call <vscale x 8 x i32> @llvm.experimental.stepvector.nxv8i32()
336 ret <vscale x 8 x i32> %v
339 declare <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
341 define <vscale x 16 x i32> @stepvector_nxv16i32() {
342 ; CHECK-LABEL: stepvector_nxv16i32:
344 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
345 ; CHECK-NEXT: vid.v v8
347 %v = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
348 ret <vscale x 16 x i32> %v
351 define <vscale x 16 x i32> @add_stepvector_nxv16i32() {
352 ; CHECK-LABEL: add_stepvector_nxv16i32:
353 ; CHECK: # %bb.0: # %entry
354 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
355 ; CHECK-NEXT: vid.v v8
356 ; CHECK-NEXT: vadd.vv v8, v8, v8
359 %0 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
360 %1 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
361 %2 = add <vscale x 16 x i32> %0, %1
362 ret <vscale x 16 x i32> %2
365 define <vscale x 16 x i32> @mul_stepvector_nxv16i32() {
366 ; CHECK-LABEL: mul_stepvector_nxv16i32:
367 ; CHECK: # %bb.0: # %entry
368 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
369 ; CHECK-NEXT: vid.v v8
370 ; CHECK-NEXT: li a0, 3
371 ; CHECK-NEXT: vmul.vx v8, v8, a0
374 %2 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
375 %3 = mul <vscale x 16 x i32> %2, splat (i32 3)
376 ret <vscale x 16 x i32> %3
379 define <vscale x 16 x i32> @shl_stepvector_nxv16i32() {
380 ; CHECK-LABEL: shl_stepvector_nxv16i32:
381 ; CHECK: # %bb.0: # %entry
382 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
383 ; CHECK-NEXT: vid.v v8
384 ; CHECK-NEXT: vsll.vi v8, v8, 2
387 %2 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
388 %3 = shl <vscale x 16 x i32> %2, splat (i32 2)
389 ret <vscale x 16 x i32> %3
392 declare <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
394 define <vscale x 1 x i64> @stepvector_nxv1i64() {
395 ; CHECK-LABEL: stepvector_nxv1i64:
397 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
398 ; CHECK-NEXT: vid.v v8
400 %v = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
401 ret <vscale x 1 x i64> %v
404 declare <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
406 define <vscale x 2 x i64> @stepvector_nxv2i64() {
407 ; CHECK-LABEL: stepvector_nxv2i64:
409 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
410 ; CHECK-NEXT: vid.v v8
412 %v = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
413 ret <vscale x 2 x i64> %v
416 declare <vscale x 3 x i64> @llvm.experimental.stepvector.nxv3i64()
418 define <vscale x 3 x i64> @stepvector_nxv3i64() {
419 ; CHECK-LABEL: stepvector_nxv3i64:
421 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
422 ; CHECK-NEXT: vid.v v8
424 %v = call <vscale x 3 x i64> @llvm.experimental.stepvector.nxv3i64()
425 ret <vscale x 3 x i64> %v
428 declare <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
430 define <vscale x 4 x i64> @stepvector_nxv4i64() {
431 ; CHECK-LABEL: stepvector_nxv4i64:
433 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
434 ; CHECK-NEXT: vid.v v8
436 %v = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
437 ret <vscale x 4 x i64> %v
440 declare <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
442 define <vscale x 8 x i64> @stepvector_nxv8i64() {
443 ; CHECK-LABEL: stepvector_nxv8i64:
445 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
446 ; CHECK-NEXT: vid.v v8
448 %v = call <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
449 ret <vscale x 8 x i64> %v
452 define <vscale x 8 x i64> @add_stepvector_nxv8i64() {
453 ; CHECK-LABEL: add_stepvector_nxv8i64:
454 ; CHECK: # %bb.0: # %entry
455 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
456 ; CHECK-NEXT: vid.v v8
457 ; CHECK-NEXT: vadd.vv v8, v8, v8
460 %0 = call <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
461 %1 = call <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
462 %2 = add <vscale x 8 x i64> %0, %1
463 ret <vscale x 8 x i64> %2
466 define <vscale x 8 x i64> @mul_stepvector_nxv8i64() {
467 ; CHECK-LABEL: mul_stepvector_nxv8i64:
468 ; CHECK: # %bb.0: # %entry
469 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
470 ; CHECK-NEXT: vid.v v8
471 ; CHECK-NEXT: li a0, 3
472 ; CHECK-NEXT: vmul.vx v8, v8, a0
475 %2 = call <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
476 %3 = mul <vscale x 8 x i64> %2, splat (i64 3)
477 ret <vscale x 8 x i64> %3
480 define <vscale x 8 x i64> @mul_bigimm_stepvector_nxv8i64() {
481 ; RV32-LABEL: mul_bigimm_stepvector_nxv8i64:
482 ; RV32: # %bb.0: # %entry
483 ; RV32-NEXT: addi sp, sp, -16
484 ; RV32-NEXT: .cfi_def_cfa_offset 16
485 ; RV32-NEXT: li a0, 7
486 ; RV32-NEXT: sw a0, 12(sp)
487 ; RV32-NEXT: lui a0, 797989
488 ; RV32-NEXT: addi a0, a0, -683
489 ; RV32-NEXT: sw a0, 8(sp)
490 ; RV32-NEXT: addi a0, sp, 8
491 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
492 ; RV32-NEXT: vlse64.v v8, (a0), zero
493 ; RV32-NEXT: vid.v v16
494 ; RV32-NEXT: vmul.vv v8, v16, v8
495 ; RV32-NEXT: addi sp, sp, 16
498 ; RV64-LABEL: mul_bigimm_stepvector_nxv8i64:
499 ; RV64: # %bb.0: # %entry
500 ; RV64-NEXT: vsetvli a0, zero, e64, m8, ta, ma
501 ; RV64-NEXT: vid.v v8
502 ; RV64-NEXT: lui a0, 1987
503 ; RV64-NEXT: addiw a0, a0, -731
504 ; RV64-NEXT: slli a0, a0, 12
505 ; RV64-NEXT: addi a0, a0, -683
506 ; RV64-NEXT: vmul.vx v8, v8, a0
509 %2 = call <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
510 %3 = mul <vscale x 8 x i64> %2, splat (i64 33333333333)
511 ret <vscale x 8 x i64> %3
514 define <vscale x 8 x i64> @shl_stepvector_nxv8i64() {
515 ; CHECK-LABEL: shl_stepvector_nxv8i64:
516 ; CHECK: # %bb.0: # %entry
517 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
518 ; CHECK-NEXT: vid.v v8
519 ; CHECK-NEXT: vsll.vi v8, v8, 2
522 %2 = call <vscale x 8 x i64> @llvm.experimental.stepvector.nxv8i64()
523 %3 = shl <vscale x 8 x i64> %2, splat (i64 2)
524 ret <vscale x 8 x i64> %3
527 declare <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
529 define <vscale x 16 x i64> @stepvector_nxv16i64() {
530 ; RV32-LABEL: stepvector_nxv16i64:
532 ; RV32-NEXT: addi sp, sp, -16
533 ; RV32-NEXT: .cfi_def_cfa_offset 16
534 ; RV32-NEXT: sw zero, 12(sp)
535 ; RV32-NEXT: csrr a0, vlenb
536 ; RV32-NEXT: sw a0, 8(sp)
537 ; RV32-NEXT: addi a0, sp, 8
538 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
539 ; RV32-NEXT: vlse64.v v16, (a0), zero
540 ; RV32-NEXT: vid.v v8
541 ; RV32-NEXT: vadd.vv v16, v8, v16
542 ; RV32-NEXT: addi sp, sp, 16
545 ; RV64-LABEL: stepvector_nxv16i64:
547 ; RV64-NEXT: csrr a0, vlenb
548 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
549 ; RV64-NEXT: vid.v v8
550 ; RV64-NEXT: vadd.vx v16, v8, a0
552 %v = call <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
553 ret <vscale x 16 x i64> %v
556 define <vscale x 16 x i64> @add_stepvector_nxv16i64() {
557 ; RV32-LABEL: add_stepvector_nxv16i64:
558 ; RV32: # %bb.0: # %entry
559 ; RV32-NEXT: addi sp, sp, -16
560 ; RV32-NEXT: .cfi_def_cfa_offset 16
561 ; RV32-NEXT: sw zero, 12(sp)
562 ; RV32-NEXT: csrr a0, vlenb
563 ; RV32-NEXT: slli a0, a0, 1
564 ; RV32-NEXT: sw a0, 8(sp)
565 ; RV32-NEXT: addi a0, sp, 8
566 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
567 ; RV32-NEXT: vlse64.v v16, (a0), zero
568 ; RV32-NEXT: vid.v v8
569 ; RV32-NEXT: vadd.vv v8, v8, v8
570 ; RV32-NEXT: vadd.vv v16, v8, v16
571 ; RV32-NEXT: addi sp, sp, 16
574 ; RV64-LABEL: add_stepvector_nxv16i64:
575 ; RV64: # %bb.0: # %entry
576 ; RV64-NEXT: csrr a0, vlenb
577 ; RV64-NEXT: slli a0, a0, 1
578 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
579 ; RV64-NEXT: vid.v v8
580 ; RV64-NEXT: vadd.vv v8, v8, v8
581 ; RV64-NEXT: vadd.vx v16, v8, a0
584 %0 = call <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
585 %1 = call <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
586 %2 = add <vscale x 16 x i64> %0, %1
587 ret <vscale x 16 x i64> %2
590 define <vscale x 16 x i64> @mul_stepvector_nxv16i64() {
591 ; RV32-LABEL: mul_stepvector_nxv16i64:
592 ; RV32: # %bb.0: # %entry
593 ; RV32-NEXT: addi sp, sp, -16
594 ; RV32-NEXT: .cfi_def_cfa_offset 16
595 ; RV32-NEXT: sw zero, 12(sp)
596 ; RV32-NEXT: csrr a0, vlenb
597 ; RV32-NEXT: slli a1, a0, 1
598 ; RV32-NEXT: add a0, a1, a0
599 ; RV32-NEXT: sw a0, 8(sp)
600 ; RV32-NEXT: addi a0, sp, 8
601 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
602 ; RV32-NEXT: vlse64.v v16, (a0), zero
603 ; RV32-NEXT: vid.v v8
604 ; RV32-NEXT: li a0, 3
605 ; RV32-NEXT: vmul.vx v8, v8, a0
606 ; RV32-NEXT: vadd.vv v16, v8, v16
607 ; RV32-NEXT: addi sp, sp, 16
610 ; RV64-LABEL: mul_stepvector_nxv16i64:
611 ; RV64: # %bb.0: # %entry
612 ; RV64-NEXT: vsetvli a0, zero, e64, m8, ta, ma
613 ; RV64-NEXT: vid.v v8
614 ; RV64-NEXT: li a0, 3
615 ; RV64-NEXT: vmul.vx v8, v8, a0
616 ; RV64-NEXT: csrr a0, vlenb
617 ; RV64-NEXT: slli a1, a0, 1
618 ; RV64-NEXT: add a0, a1, a0
619 ; RV64-NEXT: vadd.vx v16, v8, a0
622 %2 = call <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
623 %3 = mul <vscale x 16 x i64> %2, splat (i64 3)
624 ret <vscale x 16 x i64> %3
627 define <vscale x 16 x i64> @mul_bigimm_stepvector_nxv16i64() {
628 ; RV32-LABEL: mul_bigimm_stepvector_nxv16i64:
629 ; RV32: # %bb.0: # %entry
630 ; RV32-NEXT: addi sp, sp, -16
631 ; RV32-NEXT: .cfi_def_cfa_offset 16
632 ; RV32-NEXT: li a0, 7
633 ; RV32-NEXT: sw a0, 12(sp)
634 ; RV32-NEXT: lui a0, 797989
635 ; RV32-NEXT: addi a0, a0, -683
636 ; RV32-NEXT: sw a0, 8(sp)
637 ; RV32-NEXT: csrr a0, vlenb
638 ; RV32-NEXT: lui a1, 11557
639 ; RV32-NEXT: addi a1, a1, -683
640 ; RV32-NEXT: mul a1, a0, a1
641 ; RV32-NEXT: sw a1, 0(sp)
642 ; RV32-NEXT: srli a0, a0, 3
643 ; RV32-NEXT: lui a1, 92455
644 ; RV32-NEXT: addi a1, a1, -1368
645 ; RV32-NEXT: mulhu a1, a0, a1
646 ; RV32-NEXT: slli a2, a0, 1
647 ; RV32-NEXT: slli a0, a0, 6
648 ; RV32-NEXT: sub a0, a0, a2
649 ; RV32-NEXT: add a0, a1, a0
650 ; RV32-NEXT: sw a0, 4(sp)
651 ; RV32-NEXT: addi a0, sp, 8
652 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
653 ; RV32-NEXT: vlse64.v v8, (a0), zero
654 ; RV32-NEXT: mv a0, sp
655 ; RV32-NEXT: vlse64.v v16, (a0), zero
656 ; RV32-NEXT: vid.v v24
657 ; RV32-NEXT: vmul.vv v8, v24, v8
658 ; RV32-NEXT: vadd.vv v16, v8, v16
659 ; RV32-NEXT: addi sp, sp, 16
662 ; RV64-LABEL: mul_bigimm_stepvector_nxv16i64:
663 ; RV64: # %bb.0: # %entry
664 ; RV64-NEXT: csrr a0, vlenb
665 ; RV64-NEXT: lui a1, 1987
666 ; RV64-NEXT: addiw a1, a1, -731
667 ; RV64-NEXT: slli a1, a1, 12
668 ; RV64-NEXT: addi a1, a1, -683
669 ; RV64-NEXT: mul a0, a0, a1
670 ; RV64-NEXT: vsetvli a2, zero, e64, m8, ta, ma
671 ; RV64-NEXT: vid.v v8
672 ; RV64-NEXT: vmul.vx v8, v8, a1
673 ; RV64-NEXT: vadd.vx v16, v8, a0
676 %2 = call <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
677 %3 = mul <vscale x 16 x i64> %2, splat (i64 33333333333)
678 ret <vscale x 16 x i64> %3
681 define <vscale x 16 x i64> @shl_stepvector_nxv16i64() {
682 ; RV32-LABEL: shl_stepvector_nxv16i64:
683 ; RV32: # %bb.0: # %entry
684 ; RV32-NEXT: addi sp, sp, -16
685 ; RV32-NEXT: .cfi_def_cfa_offset 16
686 ; RV32-NEXT: sw zero, 12(sp)
687 ; RV32-NEXT: csrr a0, vlenb
688 ; RV32-NEXT: slli a0, a0, 2
689 ; RV32-NEXT: sw a0, 8(sp)
690 ; RV32-NEXT: addi a0, sp, 8
691 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
692 ; RV32-NEXT: vlse64.v v16, (a0), zero
693 ; RV32-NEXT: vid.v v8
694 ; RV32-NEXT: vsll.vi v8, v8, 2
695 ; RV32-NEXT: vadd.vv v16, v8, v16
696 ; RV32-NEXT: addi sp, sp, 16
699 ; RV64-LABEL: shl_stepvector_nxv16i64:
700 ; RV64: # %bb.0: # %entry
701 ; RV64-NEXT: csrr a0, vlenb
702 ; RV64-NEXT: slli a0, a0, 2
703 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
704 ; RV64-NEXT: vid.v v8
705 ; RV64-NEXT: vsll.vi v8, v8, 2
706 ; RV64-NEXT: vadd.vx v16, v8, a0
709 %2 = call <vscale x 16 x i64> @llvm.experimental.stepvector.nxv16i64()
710 %3 = shl <vscale x 16 x i64> %2, splat (i64 2)
711 ret <vscale x 16 x i64> %3
714 ; maximum step is 4 * 2 = 8, so maximum step value is 7, so hi 61 bits are known
716 define <vscale x 2 x i64> @hi_bits_known_zero() vscale_range(2, 4) {
717 ; CHECK-LABEL: hi_bits_known_zero:
719 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
720 ; CHECK-NEXT: vmv.v.i v8, 0
722 %step = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
723 %and = and <vscale x 2 x i64> %step, splat (i64 u0xfffffffffffffff8)
724 ret <vscale x 2 x i64> %and
727 ; the maximum step here overflows so don't set the known hi bits
728 define <vscale x 2 x i64> @hi_bits_known_zero_overflow() vscale_range(2, 4) {
729 ; CHECK-LABEL: hi_bits_known_zero_overflow:
731 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
732 ; CHECK-NEXT: vid.v v8
733 ; CHECK-NEXT: li a0, -1
734 ; CHECK-NEXT: vmul.vx v8, v8, a0
735 ; CHECK-NEXT: vand.vi v8, v8, -8
737 %step = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
738 %step.mul = mul <vscale x 2 x i64> %step, splat (i64 u0xffffffffffffffff)
739 %and = and <vscale x 2 x i64> %step.mul, splat (i64 u0xfffffffffffffff8)
740 ret <vscale x 2 x i64> %and
743 ; step values are multiple of 8, so lo 3 bits are known zero
744 define <vscale x 2 x i64> @lo_bits_known_zero() {
745 ; CHECK-LABEL: lo_bits_known_zero:
747 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
748 ; CHECK-NEXT: vmv.v.i v8, 0
750 %step = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
751 %step.mul = mul <vscale x 2 x i64> %step, splat (i64 8)
752 %and = and <vscale x 2 x i64> %step.mul, splat (i64 7)
753 ret <vscale x 2 x i64> %and