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
8 define <vscale x 16 x i8> @index_ii_i8() {
9 ; CHECK-LABEL: index_ii_i8:
11 ; CHECK-NEXT: index z0.b, #-16, #15
13 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 -16, i8 15)
14 ret <vscale x 16 x i8> %out
17 define <vscale x 8 x i16> @index_ii_i16() {
18 ; CHECK-LABEL: index_ii_i16:
20 ; CHECK-NEXT: index z0.h, #15, #-16
22 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 15, i16 -16)
23 ret <vscale x 8 x i16> %out
26 define <vscale x 4 x i32> @index_ii_i32() {
27 ; CHECK-LABEL: index_ii_i32:
29 ; CHECK-NEXT: index z0.s, #-16, #15
31 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 -16, i32 15)
32 ret <vscale x 4 x i32> %out
35 define <vscale x 2 x i64> @index_ii_i64() {
36 ; CHECK-LABEL: index_ii_i64:
38 ; CHECK-NEXT: index z0.d, #15, #-16
40 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 15, i64 -16)
41 ret <vscale x 2 x i64> %out
44 define <vscale x 2 x i64> @index_ii_range() {
45 ; CHECK-LABEL: index_ii_range:
47 ; CHECK-NEXT: mov w8, #16 // =0x10
48 ; CHECK-NEXT: mov x9, #-17 // =0xffffffffffffffef
49 ; CHECK-NEXT: index z0.d, x9, x8
51 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 -17, i64 16)
52 ret <vscale x 2 x i64> %out
55 define <vscale x 8 x i16> @index_ii_range_combine(i16 %a) {
56 ; CHECK-LABEL: index_ii_range_combine:
58 ; CHECK-NEXT: index z0.h, #0, #8
59 ; CHECK-NEXT: orr z0.h, z0.h, #0x2
61 %val2 = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 0, i16 2)
62 %val3 = shl <vscale x 8 x i16> %val2, splat(i16 2)
63 %out = add <vscale x 8 x i16> %val3, splat(i16 2)
64 ret <vscale x 8 x i16> %out
68 ; INDEX (IMMEDIATE, SCALAR)
71 define <vscale x 16 x i8> @index_ir_i8(i8 %a) {
72 ; CHECK-LABEL: index_ir_i8:
74 ; CHECK-NEXT: index z0.b, #15, w0
76 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 15, i8 %a)
77 ret <vscale x 16 x i8> %out
80 define <vscale x 8 x i16> @index_ir_i16(i16 %a) {
81 ; CHECK-LABEL: index_ir_i16:
83 ; CHECK-NEXT: index z0.h, #-16, w0
85 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 -16, i16 %a)
86 ret <vscale x 8 x i16> %out
89 define <vscale x 4 x i32> @index_ir_i32(i32 %a) {
90 ; CHECK-LABEL: index_ir_i32:
92 ; CHECK-NEXT: index z0.s, #15, w0
94 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 15, i32 %a)
95 ret <vscale x 4 x i32> %out
98 define <vscale x 2 x i64> @index_ir_i64(i64 %a) {
99 ; CHECK-LABEL: index_ir_i64:
101 ; CHECK-NEXT: index z0.d, #-16, x0
103 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 -16, i64 %a)
104 ret <vscale x 2 x i64> %out
107 define <vscale x 4 x i32> @index_ir_range(i32 %a) {
108 ; CHECK-LABEL: index_ir_range:
110 ; CHECK-NEXT: mov w8, #-17 // =0xffffffef
111 ; CHECK-NEXT: index z0.s, w8, w0
113 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 -17, i32 %a)
114 ret <vscale x 4 x i32> %out
117 define <vscale x 4 x i32> @index_ir_range_combine(i32 %a) {
118 ; CHECK-LABEL: index_ir_range_combine:
120 ; CHECK-NEXT: index z0.s, #0, w0
122 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 2, i32 1)
123 %tmp1 = sub <vscale x 4 x i32> %tmp, splat(i32 2)
124 %val2 = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
125 %val3 = shufflevector <vscale x 4 x i32> %val2, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
126 %out = mul <vscale x 4 x i32> %tmp1, %val3
127 ret <vscale x 4 x i32> %out
131 ; INDEX (SCALAR, IMMEDIATE)
134 define <vscale x 16 x i8> @index_ri_i8(i8 %a) {
135 ; CHECK-LABEL: index_ri_i8:
137 ; CHECK-NEXT: index z0.b, w0, #-16
139 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 -16)
140 ret <vscale x 16 x i8> %out
143 define <vscale x 8 x i16> @index_ri_i16(i16 %a) {
144 ; CHECK-LABEL: index_ri_i16:
146 ; CHECK-NEXT: index z0.h, w0, #15
148 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 15)
149 ret <vscale x 8 x i16> %out
152 define <vscale x 4 x i32> @index_ri_i32(i32 %a) {
153 ; CHECK-LABEL: index_ri_i32:
155 ; CHECK-NEXT: index z0.s, w0, #-16
157 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 -16)
158 ret <vscale x 4 x i32> %out
161 define <vscale x 2 x i64> @index_ri_i64(i64 %a) {
162 ; CHECK-LABEL: index_ri_i64:
164 ; CHECK-NEXT: index z0.d, x0, #15
166 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 15)
167 ret <vscale x 2 x i64> %out
170 define <vscale x 8 x i16> @index_ri_range(i16 %a) {
171 ; CHECK-LABEL: index_ri_range:
173 ; CHECK-NEXT: mov w8, #16 // =0x10
174 ; CHECK-NEXT: index z0.h, w0, w8
176 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 16)
177 ret <vscale x 8 x i16> %out
184 define <vscale x 16 x i8> @index_rr_i8(i8 %a, i8 %b) {
185 ; CHECK-LABEL: index_rr_i8:
187 ; CHECK-NEXT: index z0.b, w0, w1
189 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 %b)
190 ret <vscale x 16 x i8> %out
193 define <vscale x 8 x i16> @index_rr_i16(i16 %a, i16 %b) {
194 ; CHECK-LABEL: index_rr_i16:
196 ; CHECK-NEXT: index z0.h, w0, w1
198 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 %b)
199 ret <vscale x 8 x i16> %out
202 define <vscale x 4 x i32> @index_rr_i32(i32 %a, i32 %b) {
203 ; CHECK-LABEL: index_rr_i32:
205 ; CHECK-NEXT: index z0.s, w0, w1
207 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 %b)
208 ret <vscale x 4 x i32> %out
211 define <vscale x 2 x i64> @index_rr_i64(i64 %a, i64 %b) {
212 ; CHECK-LABEL: index_rr_i64:
214 ; CHECK-NEXT: index z0.d, x0, x1
216 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 %b)
217 ret <vscale x 2 x i64> %out
220 define <vscale x 4 x i32> @index_rr_i32_combine(i32 %a, i32 %b) {
221 ; CHECK-LABEL: index_rr_i32_combine:
223 ; CHECK-NEXT: index z0.s, w0, w1
225 %val = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
226 %val1 = shufflevector <vscale x 4 x i32> %val, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
227 %val2 = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
228 %val3 = shufflevector <vscale x 4 x i32> %val2, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
229 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 0, i32 1)
230 %tmp1 = mul <vscale x 4 x i32> %tmp, %val3
231 %out = add <vscale x 4 x i32> %tmp1, %val1
232 ret <vscale x 4 x i32> %out
235 define <vscale x 4 x i32> @index_rr_i32_not_combine(i32 %a, i32 %b) {
236 ; CHECK-LABEL: index_rr_i32_not_combine:
238 ; CHECK-NEXT: index z0.s, #0, #1
239 ; CHECK-NEXT: mov z1.s, w0
240 ; CHECK-NEXT: mov z2.s, w1
241 ; CHECK-NEXT: ptrue p0.s
242 ; CHECK-NEXT: mla z1.s, p0/m, z0.s, z2.s
243 ; CHECK-NEXT: add z0.s, z1.s, z0.s
245 %val = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
246 %val1 = shufflevector <vscale x 4 x i32> %val, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
247 %val2 = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
248 %val3 = shufflevector <vscale x 4 x i32> %val2, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
249 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 0, i32 1)
250 %tmp1 = mul <vscale x 4 x i32> %tmp, %val3
251 %tmp2 = add <vscale x 4 x i32> %tmp1, %val1
252 %out = add <vscale x 4 x i32> %tmp2, %tmp
253 ret <vscale x 4 x i32> %out
256 declare <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8, i8)
257 declare <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16, i16)
258 declare <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32, i32)
259 declare <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64, i64)