1 ; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -asm-verbose=0 < %s | FileCheck %s
7 define <vscale x 2 x i64> @masked_load_nxv2i64(ptr %a, <vscale x 2 x i1> %mask) nounwind {
8 ; CHECK-LABEL: masked_load_nxv2i64:
9 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
11 %load = call <vscale x 2 x i64> @llvm.masked.load.nxv2i64(ptr %a, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x i64> undef)
12 ret <vscale x 2 x i64> %load
15 define <vscale x 4 x i32> @masked_load_nxv4i32(ptr %a, <vscale x 4 x i1> %mask) nounwind {
16 ; CHECK-LABEL: masked_load_nxv4i32:
17 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
19 %load = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32(ptr %a, i32 4, <vscale x 4 x i1> %mask, <vscale x 4 x i32> undef)
20 ret <vscale x 4 x i32> %load
23 define <vscale x 8 x i16> @masked_load_nxv8i16(ptr %a, <vscale x 8 x i1> %mask) nounwind {
24 ; CHECK-LABEL: masked_load_nxv8i16:
25 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
27 %load = call <vscale x 8 x i16> @llvm.masked.load.nxv8i16(ptr %a, i32 2, <vscale x 8 x i1> %mask, <vscale x 8 x i16> undef)
28 ret <vscale x 8 x i16> %load
31 define <vscale x 16 x i8> @masked_load_nxv16i8(ptr %a, <vscale x 16 x i1> %mask) nounwind {
32 ; CHECK-LABEL: masked_load_nxv16i8:
33 ; CHECK-NEXT: ld1b { z0.b }, p0/z, [x0]
35 %load = call <vscale x 16 x i8> @llvm.masked.load.nxv16i8(ptr %a, i32 1, <vscale x 16 x i1> %mask, <vscale x 16 x i8> undef)
36 ret <vscale x 16 x i8> %load
39 define <vscale x 2 x double> @masked_load_nxv2f64(ptr %a, <vscale x 2 x i1> %mask) nounwind {
40 ; CHECK-LABEL: masked_load_nxv2f64:
41 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
43 %load = call <vscale x 2 x double> @llvm.masked.load.nxv2f64(ptr %a, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x double> undef)
44 ret <vscale x 2 x double> %load
47 define <vscale x 2 x float> @masked_load_nxv2f32(ptr %a, <vscale x 2 x i1> %mask) nounwind {
48 ; CHECK-LABEL: masked_load_nxv2f32:
49 ; CHECK-NEXT: ld1w { z0.d }, p0/z, [x0]
51 %load = call <vscale x 2 x float> @llvm.masked.load.nxv2f32(ptr %a, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x float> undef)
52 ret <vscale x 2 x float> %load
55 define <vscale x 2 x half> @masked_load_nxv2f16(ptr %a, <vscale x 2 x i1> %mask) nounwind {
56 ; CHECK-LABEL: masked_load_nxv2f16:
57 ; CHECK-NEXT: ld1h { z0.d }, p0/z, [x0]
59 %load = call <vscale x 2 x half> @llvm.masked.load.nxv2f16(ptr %a, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x half> undef)
60 ret <vscale x 2 x half> %load
63 define <vscale x 2 x bfloat> @masked_load_nxv2bf16(ptr %a, <vscale x 2 x i1> %mask) nounwind #0 {
64 ; CHECK-LABEL: masked_load_nxv2bf16:
65 ; CHECK-NEXT: ld1h { z0.d }, p0/z, [x0]
67 %load = call <vscale x 2 x bfloat> @llvm.masked.load.nxv2bf16(ptr %a, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x bfloat> undef)
68 ret <vscale x 2 x bfloat> %load
71 define <vscale x 4 x float> @masked_load_nxv4f32(ptr %a, <vscale x 4 x i1> %mask) nounwind {
72 ; CHECK-LABEL: masked_load_nxv4f32:
73 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
75 %load = call <vscale x 4 x float> @llvm.masked.load.nxv4f32(ptr %a, i32 4, <vscale x 4 x i1> %mask, <vscale x 4 x float> undef)
76 ret <vscale x 4 x float> %load
79 define <vscale x 4 x half> @masked_load_nxv4f16(ptr %a, <vscale x 4 x i1> %mask) nounwind {
80 ; CHECK-LABEL: masked_load_nxv4f16:
81 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x0]
83 %load = call <vscale x 4 x half> @llvm.masked.load.nxv4f16(ptr %a, i32 2, <vscale x 4 x i1> %mask, <vscale x 4 x half> undef)
84 ret <vscale x 4 x half> %load
87 define <vscale x 4 x bfloat> @masked_load_nxv4bf16(ptr %a, <vscale x 4 x i1> %mask) nounwind #0 {
88 ; CHECK-LABEL: masked_load_nxv4bf16:
89 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x0]
91 %load = call <vscale x 4 x bfloat> @llvm.masked.load.nxv4bf16(ptr %a, i32 2, <vscale x 4 x i1> %mask, <vscale x 4 x bfloat> undef)
92 ret <vscale x 4 x bfloat> %load
95 define <vscale x 8 x half> @masked_load_nxv8f16(ptr %a, <vscale x 8 x i1> %mask) nounwind {
96 ; CHECK-LABEL: masked_load_nxv8f16:
97 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
99 %load = call <vscale x 8 x half> @llvm.masked.load.nxv8f16(ptr %a, i32 2, <vscale x 8 x i1> %mask, <vscale x 8 x half> undef)
100 ret <vscale x 8 x half> %load
103 define <vscale x 8 x bfloat> @masked_load_nxv8bf16(ptr %a, <vscale x 8 x i1> %mask) nounwind #0 {
104 ; CHECK-LABEL: masked_load_nxv8bf16:
105 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
107 %load = call <vscale x 8 x bfloat> @llvm.masked.load.nxv8bf16(ptr %a, i32 2, <vscale x 8 x i1> %mask, <vscale x 8 x bfloat> undef)
108 ret <vscale x 8 x bfloat> %load
111 define <vscale x 4 x i32> @masked_load_passthru(ptr %a, <vscale x 4 x i1> %mask, <vscale x 4 x i32> %passthru) nounwind {
112 ; CHECK-LABEL: masked_load_passthru:
113 ; CHECK-NEXT: ld1w { z1.s }, p0/z, [x0]
114 ; CHECK-NEXT: mov z0.s, p0/m, z1.s
116 %load = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32(ptr %a, i32 4, <vscale x 4 x i1> %mask, <vscale x 4 x i32> %passthru)
117 ret <vscale x 4 x i32> %load
120 ; Masked load requires promotion
121 define <vscale x 2 x i16> @masked_load_nxv2i16(ptr noalias %in, <vscale x 2 x i1> %mask) {
122 ; CHECK-LABEL: masked_load_nxv2i16
123 ; CHECK: ld1h { z0.d }, p0/z, [x0]
125 %wide.load = call <vscale x 2 x i16> @llvm.masked.load.nxv2i16(ptr %in, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x i16> undef)
126 ret <vscale x 2 x i16> %wide.load
133 define void @masked_store_nxv2i64(ptr %a, <vscale x 2 x i64> %val, <vscale x 2 x i1> %mask) nounwind {
134 ; CHECK-LABEL: masked_store_nxv2i64:
135 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
137 call void @llvm.masked.store.nxv2i64(<vscale x 2 x i64> %val, ptr %a, i32 8, <vscale x 2 x i1> %mask)
141 define void @masked_store_nxv4i32(ptr %a, <vscale x 4 x i32> %val, <vscale x 4 x i1> %mask) nounwind {
142 ; CHECK-LABEL: masked_store_nxv4i32:
143 ; CHECK-NEXT: st1w { z0.s }, p0, [x0]
145 call void @llvm.masked.store.nxv4i32(<vscale x 4 x i32> %val, ptr %a, i32 4, <vscale x 4 x i1> %mask)
149 define void @masked_store_nxv8i16(ptr %a, <vscale x 8 x i16> %val, <vscale x 8 x i1> %mask) nounwind {
150 ; CHECK-LABEL: masked_store_nxv8i16:
151 ; CHECK-NEXT: st1h { z0.h }, p0, [x0]
153 call void @llvm.masked.store.nxv8i16(<vscale x 8 x i16> %val, ptr %a, i32 2, <vscale x 8 x i1> %mask)
157 define void @masked_store_nxv16i8(ptr %a, <vscale x 16 x i8> %val, <vscale x 16 x i1> %mask) nounwind {
158 ; CHECK-LABEL: masked_store_nxv16i8:
159 ; CHECK-NEXT: st1b { z0.b }, p0, [x0]
161 call void @llvm.masked.store.nxv16i8(<vscale x 16 x i8> %val, ptr %a, i32 1, <vscale x 16 x i1> %mask)
165 define void @masked_store_nxv2f64(ptr %a, <vscale x 2 x double> %val, <vscale x 2 x i1> %mask) nounwind {
166 ; CHECK-LABEL: masked_store_nxv2f64:
167 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
169 call void @llvm.masked.store.nxv2f64(<vscale x 2 x double> %val, ptr %a, i32 8, <vscale x 2 x i1> %mask)
173 define void @masked_store_nxv2f32(ptr %a, <vscale x 2 x float> %val, <vscale x 2 x i1> %mask) nounwind {
174 ; CHECK-LABEL: masked_store_nxv2f32:
175 ; CHECK-NEXT: st1w { z0.d }, p0, [x0]
177 call void @llvm.masked.store.nxv2f32(<vscale x 2 x float> %val, ptr %a, i32 4, <vscale x 2 x i1> %mask)
181 define void @masked_store_nxv2f16(ptr %a, <vscale x 2 x half> %val, <vscale x 2 x i1> %mask) nounwind {
182 ; CHECK-LABEL: masked_store_nxv2f16:
183 ; CHECK-NEXT: st1h { z0.d }, p0, [x0]
185 call void @llvm.masked.store.nxv2f16(<vscale x 2 x half> %val, ptr %a, i32 4, <vscale x 2 x i1> %mask)
189 define void @masked_store_nxv4f32(ptr %a, <vscale x 4 x float> %val, <vscale x 4 x i1> %mask) nounwind {
190 ; CHECK-LABEL: masked_store_nxv4f32:
191 ; CHECK-NEXT: st1w { z0.s }, p0, [x0]
193 call void @llvm.masked.store.nxv4f32(<vscale x 4 x float> %val, ptr %a, i32 4, <vscale x 4 x i1> %mask)
197 define void @masked_store_nxv4f16(ptr %a, <vscale x 4 x half> %val, <vscale x 4 x i1> %mask) nounwind {
198 ; CHECK-LABEL: masked_store_nxv4f16:
199 ; CHECK-NEXT: st1h { z0.s }, p0, [x0]
201 call void @llvm.masked.store.nxv4f16(<vscale x 4 x half> %val, ptr %a, i32 2, <vscale x 4 x i1> %mask)
205 define void @masked_store_nxv8f16(ptr %a, <vscale x 8 x half> %val, <vscale x 8 x i1> %mask) nounwind {
206 ; CHECK-LABEL: masked_store_nxv8f16:
207 ; CHECK-NEXT: st1h { z0.h }, p0, [x0]
209 call void @llvm.masked.store.nxv8f16(<vscale x 8 x half> %val, ptr %a, i32 2, <vscale x 8 x i1> %mask)
213 define void @masked_store_nxv2bf16(ptr %a, <vscale x 2 x bfloat> %val, <vscale x 2 x i1> %mask) nounwind #0 {
214 ; CHECK-LABEL: masked_store_nxv2bf16:
215 ; CHECK-NEXT: st1h { z0.d }, p0, [x0]
217 call void @llvm.masked.store.nxv2bf16(<vscale x 2 x bfloat> %val, ptr %a, i32 2, <vscale x 2 x i1> %mask)
221 define void @masked_store_nxv4bf16(ptr %a, <vscale x 4 x bfloat> %val, <vscale x 4 x i1> %mask) nounwind #0 {
222 ; CHECK-LABEL: masked_store_nxv4bf16:
223 ; CHECK-NEXT: st1h { z0.s }, p0, [x0]
225 call void @llvm.masked.store.nxv4bf16(<vscale x 4 x bfloat> %val, ptr %a, i32 2, <vscale x 4 x i1> %mask)
229 define void @masked_store_nxv8bf16(ptr %a, <vscale x 8 x bfloat> %val, <vscale x 8 x i1> %mask) nounwind #0 {
230 ; CHECK-LABEL: masked_store_nxv8bf16:
231 ; CHECK-NEXT: st1h { z0.h }, p0, [x0]
233 call void @llvm.masked.store.nxv8bf16(<vscale x 8 x bfloat> %val, ptr %a, i32 2, <vscale x 8 x i1> %mask)
238 ; Masked load store of pointer data type
241 ; Pointer of integer type
243 define <vscale x 2 x ptr> @masked.load.nxv2p0i8(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
244 ; CHECK-LABEL: masked.load.nxv2p0i8:
245 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
247 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
248 ret <vscale x 2 x ptr> %v
250 define <vscale x 2 x ptr> @masked.load.nxv2p0i16(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
251 ; CHECK-LABEL: masked.load.nxv2p0i16:
252 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
254 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
255 ret <vscale x 2 x ptr> %v
257 define <vscale x 2 x ptr> @masked.load.nxv2p0i32(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
258 ; CHECK-LABEL: masked.load.nxv2p0i32:
259 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
261 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
262 ret <vscale x 2 x ptr> %v
264 define <vscale x 2 x ptr> @masked.load.nxv2p0i64(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
265 ; CHECK-LABEL: masked.load.nxv2p0i64:
266 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
268 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
269 ret <vscale x 2 x ptr> %v
272 ; Pointer of floating-point type
274 define <vscale x 2 x ptr> @masked.load.nxv2p0bf16(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind #0 {
275 ; CHECK-LABEL: masked.load.nxv2p0bf16:
276 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
278 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
279 ret <vscale x 2 x ptr> %v
281 define <vscale x 2 x ptr> @masked.load.nxv2p0f16(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
282 ; CHECK-LABEL: masked.load.nxv2p0f16:
283 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
285 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
286 ret <vscale x 2 x ptr> %v
288 define <vscale x 2 x ptr> @masked.load.nxv2p0f32(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
289 ; CHECK-LABEL: masked.load.nxv2p0f32:
290 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
292 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
293 ret <vscale x 2 x ptr> %v
295 define <vscale x 2 x ptr> @masked.load.nxv2p0f64(ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
296 ; CHECK-LABEL: masked.load.nxv2p0f64:
297 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
299 %v = call <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x ptr> undef)
300 ret <vscale x 2 x ptr> %v
303 ; Pointer of array type
305 define void @masked.store.nxv2p0a64i16(<vscale x 2 x ptr> %data, ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
306 ; CHECK-LABEL: masked.store.nxv2p0a64i16:
307 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
309 call void @llvm.masked.store.nxv2p0.p0(<vscale x 2 x ptr> %data, ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask)
313 ; Pointer of struct type
315 %struct = type { ptr, i32 }
316 define void @masked.store.nxv2p0s_struct(<vscale x 2 x ptr> %data, ptr %vector_ptr, <vscale x 2 x i1> %mask) nounwind {
317 ; CHECK-LABEL: masked.store.nxv2p0s_struct:
318 ; CHECK-NEXT: st1d { z0.d }, p0, [x0]
320 call void @llvm.masked.store.nxv2p0.p0(<vscale x 2 x ptr> %data, ptr %vector_ptr, i32 8, <vscale x 2 x i1> %mask)
325 declare <vscale x 2 x i64> @llvm.masked.load.nxv2i64(ptr, i32, <vscale x 2 x i1>, <vscale x 2 x i64>)
326 declare <vscale x 4 x i32> @llvm.masked.load.nxv4i32(ptr, i32, <vscale x 4 x i1>, <vscale x 4 x i32>)
327 declare <vscale x 2 x i16> @llvm.masked.load.nxv2i16(ptr, i32, <vscale x 2 x i1>, <vscale x 2 x i16>)
328 declare <vscale x 8 x i16> @llvm.masked.load.nxv8i16(ptr, i32, <vscale x 8 x i1>, <vscale x 8 x i16>)
329 declare <vscale x 16 x i8> @llvm.masked.load.nxv16i8(ptr, i32, <vscale x 16 x i1>, <vscale x 16 x i8>)
331 declare <vscale x 2 x double> @llvm.masked.load.nxv2f64(ptr, i32, <vscale x 2 x i1>, <vscale x 2 x double>)
332 declare <vscale x 2 x float> @llvm.masked.load.nxv2f32(ptr, i32, <vscale x 2 x i1>, <vscale x 2 x float>)
333 declare <vscale x 2 x half> @llvm.masked.load.nxv2f16(ptr, i32, <vscale x 2 x i1>, <vscale x 2 x half>)
334 declare <vscale x 4 x float> @llvm.masked.load.nxv4f32(ptr, i32, <vscale x 4 x i1>, <vscale x 4 x float>)
335 declare <vscale x 4 x half> @llvm.masked.load.nxv4f16(ptr, i32, <vscale x 4 x i1>, <vscale x 4 x half>)
336 declare <vscale x 8 x half> @llvm.masked.load.nxv8f16(ptr, i32, <vscale x 8 x i1>, <vscale x 8 x half>)
337 declare <vscale x 2 x bfloat> @llvm.masked.load.nxv2bf16(ptr, i32, <vscale x 2 x i1>, <vscale x 2 x bfloat>)
338 declare <vscale x 4 x bfloat> @llvm.masked.load.nxv4bf16(ptr, i32, <vscale x 4 x i1>, <vscale x 4 x bfloat>)
339 declare <vscale x 8 x bfloat> @llvm.masked.load.nxv8bf16(ptr, i32, <vscale x 8 x i1>, <vscale x 8 x bfloat>)
341 declare void @llvm.masked.store.nxv2i64(<vscale x 2 x i64>, ptr, i32, <vscale x 2 x i1>)
342 declare void @llvm.masked.store.nxv4i32(<vscale x 4 x i32>, ptr, i32, <vscale x 4 x i1>)
343 declare void @llvm.masked.store.nxv8i16(<vscale x 8 x i16>, ptr, i32, <vscale x 8 x i1>)
344 declare void @llvm.masked.store.nxv16i8(<vscale x 16 x i8>, ptr, i32, <vscale x 16 x i1>)
346 declare void @llvm.masked.store.nxv2f64(<vscale x 2 x double>, ptr, i32, <vscale x 2 x i1>)
347 declare void @llvm.masked.store.nxv2f32(<vscale x 2 x float>, ptr, i32, <vscale x 2 x i1>)
348 declare void @llvm.masked.store.nxv2f16(<vscale x 2 x half>, ptr, i32, <vscale x 2 x i1>)
349 declare void @llvm.masked.store.nxv4f32(<vscale x 4 x float>, ptr, i32, <vscale x 4 x i1>)
350 declare void @llvm.masked.store.nxv4f16(<vscale x 4 x half>, ptr, i32, <vscale x 4 x i1>)
351 declare void @llvm.masked.store.nxv8f16(<vscale x 8 x half>, ptr, i32, <vscale x 8 x i1>)
352 declare void @llvm.masked.store.nxv2bf16(<vscale x 2 x bfloat>, ptr, i32, <vscale x 2 x i1>)
353 declare void @llvm.masked.store.nxv4bf16(<vscale x 4 x bfloat>, ptr, i32, <vscale x 4 x i1>)
354 declare void @llvm.masked.store.nxv8bf16(<vscale x 8 x bfloat>, ptr, i32, <vscale x 8 x i1>)
356 declare <vscale x 2 x ptr> @llvm.masked.load.nxv2p0.p0(ptr, i32 immarg, <vscale x 2 x i1>, <vscale x 2 x ptr>)
359 declare void @llvm.masked.store.nxv2p0.p0(<vscale x 2 x ptr>, ptr, i32 immarg, <vscale x 2 x i1>)
362 ; +bf16 is required for the bfloat version.
363 attributes #0 = { "target-features"="+sve,+bf16" }