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
3
4; LEGAL INTEGER TYPES
5
6define <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
10; CHECK-NEXT:    ret
11entry:
12  %0 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
13  ret <vscale x 2 x i64> %0
14}
15
16define <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
20; CHECK-NEXT:    ret
21entry:
22  %0 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
23  ret <vscale x 4 x i32> %0
24}
25
26define <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
30; CHECK-NEXT:    ret
31entry:
32  %0 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
33  ret <vscale x 8 x i16> %0
34}
35
36define <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
40; CHECK-NEXT:    ret
41entry:
42  %0 = call <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
43  ret <vscale x 16 x i8> %0
44}
45
46; ILLEGAL INTEGER TYPES
47
48define <vscale x 4 x i64> @stepvector_nxv4i64() {
49; CHECK-LABEL: stepvector_nxv4i64:
50; CHECK:       // %bb.0: // %entry
51; CHECK-NEXT:    cntd x8
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
55; CHECK-NEXT:    ret
56entry:
57  %0 = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
58  ret <vscale x 4 x i64> %0
59}
60
61define <vscale x 16 x i32> @stepvector_nxv16i32() {
62; CHECK-LABEL: stepvector_nxv16i32:
63; CHECK:       // %bb.0: // %entry
64; CHECK-NEXT:    cntw x9
65; CHECK-NEXT:    cnth x8
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
72; CHECK-NEXT:    ret
73entry:
74  %0 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
75  ret <vscale x 16 x i32> %0
76}
77
78define <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
82; CHECK-NEXT:    ret
83entry:
84  %0 = call <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
85  ret <vscale x 2 x i32> %0
86}
87
88define <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
92; CHECK-NEXT:    ret
93entry:
94  %0 = call <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()
95  ret <vscale x 4 x i16> %0
96}
97
98define <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
102; CHECK-NEXT:    ret
103entry:
104  %0 = call <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
105  ret <vscale x 8 x i8> %0
106}
107
108define <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
112; CHECK-NEXT:    ret
113entry:
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
118}
119
120define <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
125; CHECK-NEXT:    ret
126entry:
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
132}
133
134define <vscale x 8 x i8> @mul_stepvector_nxv8i8() {
135; CHECK-LABEL: mul_stepvector_nxv8i8:
136; CHECK:       // %bb.0: // %entry
137; CHECK-NEXT:    index z0.h, #0, #2
138; CHECK-NEXT:    ret
139entry:
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 = mul <vscale x 8 x i8> %2, %1
144  ret <vscale x 8 x i8> %3
145}
146
147define <vscale x 8 x i8> @shl_stepvector_nxv8i8() {
148; CHECK-LABEL: shl_stepvector_nxv8i8:
149; CHECK:       // %bb.0: // %entry
150; CHECK-NEXT:    index z0.h, #0, #4
151; CHECK-NEXT:    ret
152entry:
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 = shl <vscale x 8 x i8> %2, %1
157  ret <vscale x 8 x i8> %3
158}
159
160
161declare <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
162declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
163declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
164declare <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
165
166declare <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
167declare <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
168declare <vscale x 2 x i32> @llvm.experimental.stepvector.nxv2i32()
169declare <vscale x 8 x i8> @llvm.experimental.stepvector.nxv8i8()
170declare <vscale x 4 x i16> @llvm.experimental.stepvector.nxv4i16()
171