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 %val = insertelement <vscale x 8 x i16> poison, i16 2, i32 0
62 %val1 = shufflevector <vscale x 8 x i16> %val, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
63 %val2 = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 0, i16 2)
64 %val3 = shl <vscale x 8 x i16> %val2, %val1
65 %out = add <vscale x 8 x i16> %val3, %val1
66 ret <vscale x 8 x i16> %out
70 ; INDEX (IMMEDIATE, SCALAR)
73 define <vscale x 16 x i8> @index_ir_i8(i8 %a) {
74 ; CHECK-LABEL: index_ir_i8:
76 ; CHECK-NEXT: index z0.b, #15, w0
78 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 15, i8 %a)
79 ret <vscale x 16 x i8> %out
82 define <vscale x 8 x i16> @index_ir_i16(i16 %a) {
83 ; CHECK-LABEL: index_ir_i16:
85 ; CHECK-NEXT: index z0.h, #-16, w0
87 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 -16, i16 %a)
88 ret <vscale x 8 x i16> %out
91 define <vscale x 4 x i32> @index_ir_i32(i32 %a) {
92 ; CHECK-LABEL: index_ir_i32:
94 ; CHECK-NEXT: index z0.s, #15, w0
96 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 15, i32 %a)
97 ret <vscale x 4 x i32> %out
100 define <vscale x 2 x i64> @index_ir_i64(i64 %a) {
101 ; CHECK-LABEL: index_ir_i64:
103 ; CHECK-NEXT: index z0.d, #-16, x0
105 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 -16, i64 %a)
106 ret <vscale x 2 x i64> %out
109 define <vscale x 4 x i32> @index_ir_range(i32 %a) {
110 ; CHECK-LABEL: index_ir_range:
112 ; CHECK-NEXT: mov w8, #-17 // =0xffffffef
113 ; CHECK-NEXT: index z0.s, w8, w0
115 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 -17, i32 %a)
116 ret <vscale x 4 x i32> %out
119 define <vscale x 4 x i32> @index_ir_range_combine(i32 %a) {
120 ; CHECK-LABEL: index_ir_range_combine:
122 ; CHECK-NEXT: index z0.s, #0, w0
124 %val = insertelement <vscale x 4 x i32> poison, i32 2, i32 0
125 %val1 = shufflevector <vscale x 4 x i32> %val, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
126 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 2, i32 1)
127 %tmp1 = sub <vscale x 4 x i32> %tmp, %val1
128 %val2 = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
129 %val3 = shufflevector <vscale x 4 x i32> %val2, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
130 %out = mul <vscale x 4 x i32> %tmp1, %val3
131 ret <vscale x 4 x i32> %out
135 ; INDEX (SCALAR, IMMEDIATE)
138 define <vscale x 16 x i8> @index_ri_i8(i8 %a) {
139 ; CHECK-LABEL: index_ri_i8:
141 ; CHECK-NEXT: index z0.b, w0, #-16
143 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 -16)
144 ret <vscale x 16 x i8> %out
147 define <vscale x 8 x i16> @index_ri_i16(i16 %a) {
148 ; CHECK-LABEL: index_ri_i16:
150 ; CHECK-NEXT: index z0.h, w0, #15
152 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 15)
153 ret <vscale x 8 x i16> %out
156 define <vscale x 4 x i32> @index_ri_i32(i32 %a) {
157 ; CHECK-LABEL: index_ri_i32:
159 ; CHECK-NEXT: index z0.s, w0, #-16
161 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 -16)
162 ret <vscale x 4 x i32> %out
165 define <vscale x 2 x i64> @index_ri_i64(i64 %a) {
166 ; CHECK-LABEL: index_ri_i64:
168 ; CHECK-NEXT: index z0.d, x0, #15
170 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 15)
171 ret <vscale x 2 x i64> %out
174 define <vscale x 8 x i16> @index_ri_range(i16 %a) {
175 ; CHECK-LABEL: index_ri_range:
177 ; CHECK-NEXT: mov w8, #16 // =0x10
178 ; CHECK-NEXT: index z0.h, w0, w8
180 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 16)
181 ret <vscale x 8 x i16> %out
188 define <vscale x 16 x i8> @index_rr_i8(i8 %a, i8 %b) {
189 ; CHECK-LABEL: index_rr_i8:
191 ; CHECK-NEXT: index z0.b, w0, w1
193 %out = call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 %b)
194 ret <vscale x 16 x i8> %out
197 define <vscale x 8 x i16> @index_rr_i16(i16 %a, i16 %b) {
198 ; CHECK-LABEL: index_rr_i16:
200 ; CHECK-NEXT: index z0.h, w0, w1
202 %out = call <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 %b)
203 ret <vscale x 8 x i16> %out
206 define <vscale x 4 x i32> @index_rr_i32(i32 %a, i32 %b) {
207 ; CHECK-LABEL: index_rr_i32:
209 ; CHECK-NEXT: index z0.s, w0, w1
211 %out = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 %b)
212 ret <vscale x 4 x i32> %out
215 define <vscale x 2 x i64> @index_rr_i64(i64 %a, i64 %b) {
216 ; CHECK-LABEL: index_rr_i64:
218 ; CHECK-NEXT: index z0.d, x0, x1
220 %out = call <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 %b)
221 ret <vscale x 2 x i64> %out
224 define <vscale x 4 x i32> @index_rr_i32_combine(i32 %a, i32 %b) {
225 ; CHECK-LABEL: index_rr_i32_combine:
227 ; CHECK-NEXT: index z0.s, w0, w1
229 %val = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
230 %val1 = shufflevector <vscale x 4 x i32> %val, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
231 %val2 = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
232 %val3 = shufflevector <vscale x 4 x i32> %val2, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
233 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 0, i32 1)
234 %tmp1 = mul <vscale x 4 x i32> %tmp, %val3
235 %out = add <vscale x 4 x i32> %tmp1, %val1
236 ret <vscale x 4 x i32> %out
239 define <vscale x 4 x i32> @index_rr_i32_not_combine(i32 %a, i32 %b) {
240 ; CHECK-LABEL: index_rr_i32_not_combine:
242 ; CHECK-NEXT: index z0.s, #0, #1
243 ; CHECK-NEXT: mov z1.s, w0
244 ; CHECK-NEXT: mov z2.s, w1
245 ; CHECK-NEXT: ptrue p0.s
246 ; CHECK-NEXT: mla z1.s, p0/m, z0.s, z2.s
247 ; CHECK-NEXT: add z0.s, z1.s, z0.s
249 %val = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
250 %val1 = shufflevector <vscale x 4 x i32> %val, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
251 %val2 = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
252 %val3 = shufflevector <vscale x 4 x i32> %val2, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
253 %tmp = call <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32 0, i32 1)
254 %tmp1 = mul <vscale x 4 x i32> %tmp, %val3
255 %tmp2 = add <vscale x 4 x i32> %tmp1, %val1
256 %out = add <vscale x 4 x i32> %tmp2, %tmp
257 ret <vscale x 4 x i32> %out
260 declare <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8, i8)
261 declare <vscale x 8 x i16> @llvm.aarch64.sve.index.nxv8i16(i16, i16)
262 declare <vscale x 4 x i32> @llvm.aarch64.sve.index.nxv4i32(i32, i32)
263 declare <vscale x 2 x i64> @llvm.aarch64.sve.index.nxv2i64(i64, i64)