1 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
4 ; LD1B, LD1W, LD1H, LD1D: vector base + immediate offset (index)
5 ; e.g. ld1h { z0.s }, p0/z, [z0.s, #16]
9 define <vscale x 4 x i32> @gld1b_s_imm_offset(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
10 ; CHECK-LABEL: gld1b_s_imm_offset:
11 ; CHECK: ld1b { z0.s }, p0/z, [z0.s, #16]
13 %load = call <vscale x 4 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> %pg,
14 <vscale x 4 x i32> %base,
16 %res = zext <vscale x 4 x i8> %load to <vscale x 4 x i32>
17 ret <vscale x 4 x i32> %res
20 define <vscale x 2 x i64> @gld1b_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
21 ; CHECK-LABEL: gld1b_d_imm_offset:
22 ; CHECK: ld1b { z0.d }, p0/z, [z0.d, #16]
24 %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
25 <vscale x 2 x i64> %base,
27 %res = zext <vscale x 2 x i8> %load to <vscale x 2 x i64>
28 ret <vscale x 2 x i64> %res
32 define <vscale x 4 x i32> @gld1h_s_imm_offset(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
33 ; CHECK-LABEL: gld1h_s_imm_offset:
34 ; CHECK: ld1h { z0.s }, p0/z, [z0.s, #16]
36 %load = call <vscale x 4 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i16.nxv4i32(<vscale x 4 x i1> %pg,
37 <vscale x 4 x i32> %base,
39 %res = zext <vscale x 4 x i16> %load to <vscale x 4 x i32>
40 ret <vscale x 4 x i32> %res
43 define <vscale x 2 x i64> @gld1h_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
44 ; CHECK-LABEL: gld1h_d_imm_offset:
45 ; CHECK: ld1h { z0.d }, p0/z, [z0.d, #16]
47 %load = call <vscale x 2 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64(<vscale x 2 x i1> %pg,
48 <vscale x 2 x i64> %base,
50 %res = zext <vscale x 2 x i16> %load to <vscale x 2 x i64>
51 ret <vscale x 2 x i64> %res
55 define <vscale x 4 x i32> @gld1w_s_imm_offset(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
56 ; CHECK-LABEL: gld1w_s_imm_offset:
57 ; CHECK: ld1w { z0.s }, p0/z, [z0.s, #16]
59 %load = call <vscale x 4 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i32.nxv4i32(<vscale x 4 x i1> %pg,
60 <vscale x 4 x i32> %base,
62 ret <vscale x 4 x i32> %load
65 define <vscale x 2 x i64> @gld1w_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
66 ; CHECK-LABEL: gld1w_d_imm_offset:
67 ; CHECK: ld1w { z0.d }, p0/z, [z0.d, #16]
69 %load = call <vscale x 2 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> %pg,
70 <vscale x 2 x i64> %base,
72 %res = zext <vscale x 2 x i32> %load to <vscale x 2 x i64>
73 ret <vscale x 2 x i64> %res
76 define <vscale x 4 x float> @gld1w_s_imm_offset_float(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
77 ; CHECK-LABEL: gld1w_s_imm_offset_float:
78 ; CHECK: ld1w { z0.s }, p0/z, [z0.s, #16]
80 %load = call <vscale x 4 x float> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4f32.nxv4i32(<vscale x 4 x i1> %pg,
81 <vscale x 4 x i32> %base,
83 ret <vscale x 4 x float> %load
87 define <vscale x 2 x i64> @gld1d_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
88 ; CHECK-LABEL: gld1d_d_imm_offset:
89 ; CHECK: ld1d { z0.d }, p0/z, [z0.d, #16]
91 %load = call <vscale x 2 x i64> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i64.nxv2i64(<vscale x 2 x i1> %pg,
92 <vscale x 2 x i64> %base,
94 ret <vscale x 2 x i64> %load
97 define <vscale x 2 x double> @gld1d_d_imm_offset_double(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
98 ; CHECK-LABEL: gld1d_d_imm_offset_double:
99 ; CHECK: ld1d { z0.d }, p0/z, [z0.d, #16]
101 %load = call <vscale x 2 x double> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2f64.nxv2i64(<vscale x 2 x i1> %pg,
102 <vscale x 2 x i64> %base,
104 ret <vscale x 2 x double> %load
108 ; LD1SB, LD1SW, LD1SH: vector base + immediate offset (index)
109 ; e.g. ld1sh { z0.s }, p0/z, [z0.s, #16]
113 define <vscale x 4 x i32> @gld1sb_s_imm_offset(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
114 ; CHECK-LABEL: gld1sb_s_imm_offset:
115 ; CHECK: ld1sb { z0.s }, p0/z, [z0.s, #16]
117 %load = call <vscale x 4 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> %pg,
118 <vscale x 4 x i32> %base,
120 %res = sext <vscale x 4 x i8> %load to <vscale x 4 x i32>
121 ret <vscale x 4 x i32> %res
124 define <vscale x 2 x i64> @gld1sb_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
125 ; CHECK-LABEL: gld1sb_d_imm_offset:
126 ; CHECK: ld1sb { z0.d }, p0/z, [z0.d, #16]
128 %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
129 <vscale x 2 x i64> %base,
131 %res = sext <vscale x 2 x i8> %load to <vscale x 2 x i64>
132 ret <vscale x 2 x i64> %res
136 define <vscale x 4 x i32> @gld1sh_s_imm_offset(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
137 ; CHECK-LABEL: gld1sh_s_imm_offset:
138 ; CHECK: ld1sh { z0.s }, p0/z, [z0.s, #16]
140 %load = call <vscale x 4 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i16.nxv4i32(<vscale x 4 x i1> %pg,
141 <vscale x 4 x i32> %base,
143 %res = sext <vscale x 4 x i16> %load to <vscale x 4 x i32>
144 ret <vscale x 4 x i32> %res
147 define <vscale x 2 x i64> @gld1sh_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
148 ; CHECK-LABEL: gld1sh_d_imm_offset:
149 ; CHECK: ld1sh { z0.d }, p0/z, [z0.d, #16]
151 %load = call <vscale x 2 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64(<vscale x 2 x i1> %pg,
152 <vscale x 2 x i64> %base,
154 %res = sext <vscale x 2 x i16> %load to <vscale x 2 x i64>
155 ret <vscale x 2 x i64> %res
159 define <vscale x 2 x i64> @gld1sw_d_imm_offset(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
160 ; CHECK-LABEL: gld1sw_d_imm_offset:
161 ; CHECK: ld1sw { z0.d }, p0/z, [z0.d, #16]
163 %load = call <vscale x 2 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> %pg,
164 <vscale x 2 x i64> %base,
166 %res = sext <vscale x 2 x i32> %load to <vscale x 2 x i64>
167 ret <vscale x 2 x i64> %res
171 ; LD1B, LD1W, LD1H, LD1D: vector base + out of range immediate offset
172 ; e.g. ld1b { z0.d }, p0/z, [x0, z0.d]
176 define <vscale x 4 x i32> @gld1b_s_imm_offset_out_of_range(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
177 ; CHECK-LABEL: gld1b_s_imm_offset_out_of_range:
179 ; CHECK-NEXT: ld1b { z0.s }, p0/z, [x8, z0.s, uxtw]
181 %load = call <vscale x 4 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> %pg,
182 <vscale x 4 x i32> %base,
184 %res = zext <vscale x 4 x i8> %load to <vscale x 4 x i32>
185 ret <vscale x 4 x i32> %res
188 define <vscale x 2 x i64> @gld1b_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
189 ; CHECK-LABEL: gld1b_d_imm_offset_out_of_range:
191 ; CHECK-NEXT: ld1b { z0.d }, p0/z, [x8, z0.d]
193 %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
194 <vscale x 2 x i64> %base,
196 %res = zext <vscale x 2 x i8> %load to <vscale x 2 x i64>
197 ret <vscale x 2 x i64> %res
201 define <vscale x 4 x i32> @gld1h_s_imm_offset_out_of_range(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
202 ; CHECK-LABEL: gld1h_s_imm_offset_out_of_range:
204 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x8, z0.s, uxtw]
206 %load = call <vscale x 4 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i16.nxv4i32(<vscale x 4 x i1> %pg,
207 <vscale x 4 x i32> %base,
209 %res = zext <vscale x 4 x i16> %load to <vscale x 4 x i32>
210 ret <vscale x 4 x i32> %res
213 define <vscale x 2 x i64> @gld1h_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
214 ; CHECK-LABEL: gld1h_d_imm_offset_out_of_range:
216 ; CHECK-NEXT: ld1h { z0.d }, p0/z, [x8, z0.d]
218 %load = call <vscale x 2 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64(<vscale x 2 x i1> %pg,
219 <vscale x 2 x i64> %base,
221 %res = zext <vscale x 2 x i16> %load to <vscale x 2 x i64>
222 ret <vscale x 2 x i64> %res
226 define <vscale x 4 x i32> @gld1w_s_imm_offset_out_of_range(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
227 ; CHECK-LABEL: gld1w_s_imm_offset_out_of_range:
228 ; CHECK: mov w8, #125
229 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x8, z0.s, uxtw]
231 %load = call <vscale x 4 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i32.nxv4i32(<vscale x 4 x i1> %pg,
232 <vscale x 4 x i32> %base,
234 ret <vscale x 4 x i32> %load
237 define <vscale x 2 x i64> @gld1w_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
238 ; CHECK-LABEL: gld1w_d_imm_offset_out_of_range:
239 ; CHECK: mov w8, #125
240 ; CHECK-NEXT: ld1w { z0.d }, p0/z, [x8, z0.d]
242 %load = call <vscale x 2 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> %pg,
243 <vscale x 2 x i64> %base,
245 %res = zext <vscale x 2 x i32> %load to <vscale x 2 x i64>
246 ret <vscale x 2 x i64> %res
249 define <vscale x 4 x float> @gld1w_s_imm_offset_out_of_range_float(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
250 ; CHECK-LABEL: gld1w_s_imm_offset_out_of_range_float:
251 ; CHECK: mov w8, #125
252 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x8, z0.s, uxtw]
254 %load = call <vscale x 4 x float> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4f32.nxv4i32(<vscale x 4 x i1> %pg,
255 <vscale x 4 x i32> %base,
257 ret <vscale x 4 x float> %load
261 define <vscale x 2 x i64> @gld1d_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
262 ; CHECK-LABEL: gld1d_d_imm_offset_out_of_range:
263 ; CHECK: mov w8, #249
264 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x8, z0.d]
266 %load = call <vscale x 2 x i64> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i64.nxv2i64(<vscale x 2 x i1> %pg,
267 <vscale x 2 x i64> %base,
269 ret <vscale x 2 x i64> %load
272 define <vscale x 2 x double> @gld1d_d_imm_offset_out_of_range_double(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
273 ; CHECK-LABEL: gld1d_d_imm_offset_out_of_range_double:
274 ; CHECK: mov w8, #249
275 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x8, z0.d]
277 %load = call <vscale x 2 x double> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2f64.nxv2i64(<vscale x 2 x i1> %pg,
278 <vscale x 2 x i64> %base,
280 ret <vscale x 2 x double> %load
284 ; LD1SB, LD1SW, LD1SH: vector base + out of range immediate offset
285 ; e.g. ld1sb { z0.s }, p0/z, [x8, z0.s, uxtw]
289 define <vscale x 4 x i32> @gld1sb_s_imm_offset_out_of_range(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
290 ; CHECK-LABEL: gld1sb_s_imm_offset_out_of_range:
292 ; CHECK-NEXT: ld1sb { z0.s }, p0/z, [x8, z0.s, uxtw]
294 %load = call <vscale x 4 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> %pg,
295 <vscale x 4 x i32> %base,
297 %res = sext <vscale x 4 x i8> %load to <vscale x 4 x i32>
298 ret <vscale x 4 x i32> %res
301 define <vscale x 2 x i64> @gld1sb_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
302 ; CHECK-LABEL: gld1sb_d_imm_offset_out_of_range:
304 ; CHECK-NEXT: ld1sb { z0.d }, p0/z, [x8, z0.d]
306 %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
307 <vscale x 2 x i64> %base,
309 %res = sext <vscale x 2 x i8> %load to <vscale x 2 x i64>
310 ret <vscale x 2 x i64> %res
314 define <vscale x 4 x i32> @gld1sh_s_imm_offset_out_of_range(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %base) {
315 ; CHECK-LABEL: gld1sh_s_imm_offset_out_of_range:
317 ; CHECK-NEXT: ld1sh { z0.s }, p0/z, [x8, z0.s, uxtw]
319 %load = call <vscale x 4 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i16.nxv4i32(<vscale x 4 x i1> %pg,
320 <vscale x 4 x i32> %base,
322 %res = sext <vscale x 4 x i16> %load to <vscale x 4 x i32>
323 ret <vscale x 4 x i32> %res
326 define <vscale x 2 x i64> @gld1sh_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
327 ; CHECK-LABEL: gld1sh_d_imm_offset_out_of_range:
329 ; CHECK-NEXT: ld1sh { z0.d }, p0/z, [x8, z0.d]
331 %load = call <vscale x 2 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64(<vscale x 2 x i1> %pg,
332 <vscale x 2 x i64> %base,
334 %res = sext <vscale x 2 x i16> %load to <vscale x 2 x i64>
335 ret <vscale x 2 x i64> %res
339 define <vscale x 2 x i64> @gld1sw_d_imm_offset_out_of_range(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %base) {
340 ; CHECK-LABEL: gld1sw_d_imm_offset_out_of_range:
341 ; CHECK: mov w8, #125
342 ; CHECK-NEXT: ld1sw { z0.d }, p0/z, [x8, z0.d]
344 %load = call <vscale x 2 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> %pg,
345 <vscale x 2 x i64> %base,
347 %res = sext <vscale x 2 x i32> %load to <vscale x 2 x i64>
348 ret <vscale x 2 x i64> %res
352 declare <vscale x 4 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, i64)
353 declare <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, i64)
356 declare <vscale x 4 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i16.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, i64)
357 declare <vscale x 2 x i16> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, i64)
360 declare <vscale x 4 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4i32.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, i64)
361 declare <vscale x 2 x i32> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, i64)
363 declare <vscale x 4 x float> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv4f32.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, i64)
366 declare <vscale x 2 x i64> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i64.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, i64)
368 declare <vscale x 2 x double> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2f64.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, i64)