1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zvfh,+v \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zvfh,+v \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s
7 declare <2 x i8> @llvm.vp.load.v2i8.p0(ptr, <2 x i1>, i32)
9 define <2 x i8> @vpload_v2i8(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
10 ; CHECK-LABEL: vpload_v2i8:
12 ; CHECK-NEXT: vsetvli zero, a1, e8, mf8, ta, ma
13 ; CHECK-NEXT: vle8.v v8, (a0), v0.t
15 %load = call <2 x i8> @llvm.vp.load.v2i8.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
19 declare <3 x i8> @llvm.vp.load.v3i8.p0(ptr, <3 x i1>, i32)
21 define <3 x i8> @vpload_v3i8(ptr %ptr, <3 x i1> %m, i32 zeroext %evl) {
22 ; CHECK-LABEL: vpload_v3i8:
24 ; CHECK-NEXT: vsetvli zero, a1, e8, mf4, ta, ma
25 ; CHECK-NEXT: vle8.v v8, (a0), v0.t
27 %load = call <3 x i8> @llvm.vp.load.v3i8.p0(ptr %ptr, <3 x i1> %m, i32 %evl)
31 declare <4 x i8> @llvm.vp.load.v4i8.p0(ptr, <4 x i1>, i32)
33 define <4 x i8> @vpload_v4i8(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
34 ; CHECK-LABEL: vpload_v4i8:
36 ; CHECK-NEXT: vsetvli zero, a1, e8, mf4, ta, ma
37 ; CHECK-NEXT: vle8.v v8, (a0), v0.t
39 %load = call <4 x i8> @llvm.vp.load.v4i8.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
43 define <4 x i8> @vpload_v4i8_allones_mask(ptr %ptr, i32 zeroext %evl) {
44 ; CHECK-LABEL: vpload_v4i8_allones_mask:
46 ; CHECK-NEXT: vsetvli zero, a1, e8, mf4, ta, ma
47 ; CHECK-NEXT: vle8.v v8, (a0)
49 %load = call <4 x i8> @llvm.vp.load.v4i8.p0(ptr %ptr, <4 x i1> splat (i1 true), i32 %evl)
53 declare <8 x i8> @llvm.vp.load.v8i8.p0(ptr, <8 x i1>, i32)
55 define <8 x i8> @vpload_v8i8(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
56 ; CHECK-LABEL: vpload_v8i8:
58 ; CHECK-NEXT: vsetvli zero, a1, e8, mf2, ta, ma
59 ; CHECK-NEXT: vle8.v v8, (a0), v0.t
61 %load = call <8 x i8> @llvm.vp.load.v8i8.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
65 declare <2 x i16> @llvm.vp.load.v2i16.p0(ptr, <2 x i1>, i32)
67 define <2 x i16> @vpload_v2i16(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
68 ; CHECK-LABEL: vpload_v2i16:
70 ; CHECK-NEXT: vsetvli zero, a1, e16, mf4, ta, ma
71 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
73 %load = call <2 x i16> @llvm.vp.load.v2i16.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
77 declare <4 x i16> @llvm.vp.load.v4i16.p0(ptr, <4 x i1>, i32)
79 define <4 x i16> @vpload_v4i16(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
80 ; CHECK-LABEL: vpload_v4i16:
82 ; CHECK-NEXT: vsetvli zero, a1, e16, mf2, ta, ma
83 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
85 %load = call <4 x i16> @llvm.vp.load.v4i16.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
89 declare <8 x i16> @llvm.vp.load.v8i16.p0(ptr, <8 x i1>, i32)
91 define <8 x i16> @vpload_v8i16(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
92 ; CHECK-LABEL: vpload_v8i16:
94 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
95 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
97 %load = call <8 x i16> @llvm.vp.load.v8i16.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
101 define <8 x i16> @vpload_v8i16_allones_mask(ptr %ptr, i32 zeroext %evl) {
102 ; CHECK-LABEL: vpload_v8i16_allones_mask:
104 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
105 ; CHECK-NEXT: vle16.v v8, (a0)
107 %load = call <8 x i16> @llvm.vp.load.v8i16.p0(ptr %ptr, <8 x i1> splat (i1 true), i32 %evl)
111 declare <2 x i32> @llvm.vp.load.v2i32.p0(ptr, <2 x i1>, i32)
113 define <2 x i32> @vpload_v2i32(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
114 ; CHECK-LABEL: vpload_v2i32:
116 ; CHECK-NEXT: vsetvli zero, a1, e32, mf2, ta, ma
117 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
119 %load = call <2 x i32> @llvm.vp.load.v2i32.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
123 declare <4 x i32> @llvm.vp.load.v4i32.p0(ptr, <4 x i1>, i32)
125 define <4 x i32> @vpload_v4i32(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
126 ; CHECK-LABEL: vpload_v4i32:
128 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma
129 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
131 %load = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
135 declare <6 x i32> @llvm.vp.load.v6i32.p0(ptr, <6 x i1>, i32)
137 define <6 x i32> @vpload_v6i32(ptr %ptr, <6 x i1> %m, i32 zeroext %evl) {
138 ; CHECK-LABEL: vpload_v6i32:
140 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
141 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
143 %load = call <6 x i32> @llvm.vp.load.v6i32.p0(ptr %ptr, <6 x i1> %m, i32 %evl)
147 define <6 x i32> @vpload_v6i32_allones_mask(ptr %ptr, i32 zeroext %evl) {
148 ; CHECK-LABEL: vpload_v6i32_allones_mask:
150 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
151 ; CHECK-NEXT: vle32.v v8, (a0)
153 %load = call <6 x i32> @llvm.vp.load.v6i32.p0(ptr %ptr, <6 x i1> splat (i1 true), i32 %evl)
157 declare <8 x i32> @llvm.vp.load.v8i32.p0(ptr, <8 x i1>, i32)
159 define <8 x i32> @vpload_v8i32(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
160 ; CHECK-LABEL: vpload_v8i32:
162 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
163 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
165 %load = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
169 define <8 x i32> @vpload_v8i32_allones_mask(ptr %ptr, i32 zeroext %evl) {
170 ; CHECK-LABEL: vpload_v8i32_allones_mask:
172 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
173 ; CHECK-NEXT: vle32.v v8, (a0)
175 %load = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %ptr, <8 x i1> splat (i1 true), i32 %evl)
179 declare <2 x i64> @llvm.vp.load.v2i64.p0(ptr, <2 x i1>, i32)
181 define <2 x i64> @vpload_v2i64(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
182 ; CHECK-LABEL: vpload_v2i64:
184 ; CHECK-NEXT: vsetvli zero, a1, e64, m1, ta, ma
185 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
187 %load = call <2 x i64> @llvm.vp.load.v2i64.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
191 declare <4 x i64> @llvm.vp.load.v4i64.p0(ptr, <4 x i1>, i32)
193 define <4 x i64> @vpload_v4i64(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
194 ; CHECK-LABEL: vpload_v4i64:
196 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
197 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
199 %load = call <4 x i64> @llvm.vp.load.v4i64.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
203 define <4 x i64> @vpload_v4i64_allones_mask(ptr %ptr, i32 zeroext %evl) {
204 ; CHECK-LABEL: vpload_v4i64_allones_mask:
206 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
207 ; CHECK-NEXT: vle64.v v8, (a0)
209 %load = call <4 x i64> @llvm.vp.load.v4i64.p0(ptr %ptr, <4 x i1> splat (i1 true), i32 %evl)
213 declare <8 x i64> @llvm.vp.load.v8i64.p0(ptr, <8 x i1>, i32)
215 define <8 x i64> @vpload_v8i64(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
216 ; CHECK-LABEL: vpload_v8i64:
218 ; CHECK-NEXT: vsetvli zero, a1, e64, m4, ta, ma
219 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
221 %load = call <8 x i64> @llvm.vp.load.v8i64.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
225 declare <2 x half> @llvm.vp.load.v2f16.p0(ptr, <2 x i1>, i32)
227 define <2 x half> @vpload_v2f16(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
228 ; CHECK-LABEL: vpload_v2f16:
230 ; CHECK-NEXT: vsetvli zero, a1, e16, mf4, ta, ma
231 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
233 %load = call <2 x half> @llvm.vp.load.v2f16.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
237 define <2 x half> @vpload_v2f16_allones_mask(ptr %ptr, i32 zeroext %evl) {
238 ; CHECK-LABEL: vpload_v2f16_allones_mask:
240 ; CHECK-NEXT: vsetvli zero, a1, e16, mf4, ta, ma
241 ; CHECK-NEXT: vle16.v v8, (a0)
243 %load = call <2 x half> @llvm.vp.load.v2f16.p0(ptr %ptr, <2 x i1> splat (i1 true), i32 %evl)
247 declare <4 x half> @llvm.vp.load.v4f16.p0(ptr, <4 x i1>, i32)
249 define <4 x half> @vpload_v4f16(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
250 ; CHECK-LABEL: vpload_v4f16:
252 ; CHECK-NEXT: vsetvli zero, a1, e16, mf2, ta, ma
253 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
255 %load = call <4 x half> @llvm.vp.load.v4f16.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
259 declare <8 x half> @llvm.vp.load.v8f16.p0(ptr, <8 x i1>, i32)
261 define <8 x half> @vpload_v8f16(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
262 ; CHECK-LABEL: vpload_v8f16:
264 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
265 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
267 %load = call <8 x half> @llvm.vp.load.v8f16.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
271 declare <2 x float> @llvm.vp.load.v2f32.p0(ptr, <2 x i1>, i32)
273 define <2 x float> @vpload_v2f32(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
274 ; CHECK-LABEL: vpload_v2f32:
276 ; CHECK-NEXT: vsetvli zero, a1, e32, mf2, ta, ma
277 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
279 %load = call <2 x float> @llvm.vp.load.v2f32.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
280 ret <2 x float> %load
283 declare <4 x float> @llvm.vp.load.v4f32.p0(ptr, <4 x i1>, i32)
285 define <4 x float> @vpload_v4f32(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
286 ; CHECK-LABEL: vpload_v4f32:
288 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma
289 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
291 %load = call <4 x float> @llvm.vp.load.v4f32.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
292 ret <4 x float> %load
295 declare <8 x float> @llvm.vp.load.v8f32.p0(ptr, <8 x i1>, i32)
297 define <8 x float> @vpload_v8f32(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
298 ; CHECK-LABEL: vpload_v8f32:
300 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
301 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
303 %load = call <8 x float> @llvm.vp.load.v8f32.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
304 ret <8 x float> %load
307 define <8 x float> @vpload_v8f32_allones_mask(ptr %ptr, i32 zeroext %evl) {
308 ; CHECK-LABEL: vpload_v8f32_allones_mask:
310 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
311 ; CHECK-NEXT: vle32.v v8, (a0)
313 %load = call <8 x float> @llvm.vp.load.v8f32.p0(ptr %ptr, <8 x i1> splat (i1 true), i32 %evl)
314 ret <8 x float> %load
317 declare <2 x double> @llvm.vp.load.v2f64.p0(ptr, <2 x i1>, i32)
319 define <2 x double> @vpload_v2f64(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
320 ; CHECK-LABEL: vpload_v2f64:
322 ; CHECK-NEXT: vsetvli zero, a1, e64, m1, ta, ma
323 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
325 %load = call <2 x double> @llvm.vp.load.v2f64.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
326 ret <2 x double> %load
329 declare <4 x double> @llvm.vp.load.v4f64.p0(ptr, <4 x i1>, i32)
331 define <4 x double> @vpload_v4f64(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
332 ; CHECK-LABEL: vpload_v4f64:
334 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
335 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
337 %load = call <4 x double> @llvm.vp.load.v4f64.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
338 ret <4 x double> %load
341 define <4 x double> @vpload_v4f64_allones_mask(ptr %ptr, i32 zeroext %evl) {
342 ; CHECK-LABEL: vpload_v4f64_allones_mask:
344 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
345 ; CHECK-NEXT: vle64.v v8, (a0)
347 %load = call <4 x double> @llvm.vp.load.v4f64.p0(ptr %ptr, <4 x i1> splat (i1 true), i32 %evl)
348 ret <4 x double> %load
351 declare <8 x double> @llvm.vp.load.v8f64.p0(ptr, <8 x i1>, i32)
353 define <8 x double> @vpload_v8f64(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
354 ; CHECK-LABEL: vpload_v8f64:
356 ; CHECK-NEXT: vsetvli zero, a1, e64, m4, ta, ma
357 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
359 %load = call <8 x double> @llvm.vp.load.v8f64.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
360 ret <8 x double> %load
363 declare <32 x double> @llvm.vp.load.v32f64.p0(ptr, <32 x i1>, i32)
365 define <32 x double> @vpload_v32f64(ptr %ptr, <32 x i1> %m, i32 zeroext %evl) {
366 ; CHECK-LABEL: vpload_v32f64:
368 ; CHECK-NEXT: li a3, 16
369 ; CHECK-NEXT: mv a2, a1
370 ; CHECK-NEXT: bltu a1, a3, .LBB31_2
371 ; CHECK-NEXT: # %bb.1:
372 ; CHECK-NEXT: li a2, 16
373 ; CHECK-NEXT: .LBB31_2:
374 ; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma
375 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
376 ; CHECK-NEXT: addi a2, a1, -16
377 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
378 ; CHECK-NEXT: vslidedown.vi v0, v0, 2
379 ; CHECK-NEXT: sltu a1, a1, a2
380 ; CHECK-NEXT: addi a1, a1, -1
381 ; CHECK-NEXT: and a1, a1, a2
382 ; CHECK-NEXT: addi a0, a0, 128
383 ; CHECK-NEXT: vsetvli zero, a1, e64, m8, ta, ma
384 ; CHECK-NEXT: vle64.v v16, (a0), v0.t
386 %load = call <32 x double> @llvm.vp.load.v32f64.p0(ptr %ptr, <32 x i1> %m, i32 %evl)
387 ret <32 x double> %load
390 declare <33 x double> @llvm.vp.load.v33f64.p0(ptr, <33 x i1>, i32)
392 ; Widen to v64f64 then split into 4 x v16f64, of which 1 is empty.
394 define <33 x double> @vpload_v33f64(ptr %ptr, <33 x i1> %m, i32 zeroext %evl) {
395 ; CHECK-LABEL: vpload_v33f64:
397 ; CHECK-NEXT: vmv1r.v v8, v0
398 ; CHECK-NEXT: li a4, 32
399 ; CHECK-NEXT: mv a3, a2
400 ; CHECK-NEXT: bltu a2, a4, .LBB32_2
401 ; CHECK-NEXT: # %bb.1:
402 ; CHECK-NEXT: li a3, 32
403 ; CHECK-NEXT: .LBB32_2:
404 ; CHECK-NEXT: addi a4, a3, -16
405 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
406 ; CHECK-NEXT: vslidedown.vi v0, v8, 2
407 ; CHECK-NEXT: sltu a3, a3, a4
408 ; CHECK-NEXT: addi a3, a3, -1
409 ; CHECK-NEXT: and a3, a3, a4
410 ; CHECK-NEXT: addi a4, a1, 128
411 ; CHECK-NEXT: vsetvli zero, a3, e64, m8, ta, ma
412 ; CHECK-NEXT: vle64.v v16, (a4), v0.t
413 ; CHECK-NEXT: addi a3, a2, -32
414 ; CHECK-NEXT: sltu a4, a2, a3
415 ; CHECK-NEXT: addi a4, a4, -1
416 ; CHECK-NEXT: and a4, a4, a3
417 ; CHECK-NEXT: li a3, 16
418 ; CHECK-NEXT: bltu a4, a3, .LBB32_4
419 ; CHECK-NEXT: # %bb.3:
420 ; CHECK-NEXT: li a4, 16
421 ; CHECK-NEXT: .LBB32_4:
422 ; CHECK-NEXT: vsetivli zero, 4, e8, mf2, ta, ma
423 ; CHECK-NEXT: vslidedown.vi v0, v8, 4
424 ; CHECK-NEXT: addi a5, a1, 256
425 ; CHECK-NEXT: vsetvli zero, a4, e64, m8, ta, ma
426 ; CHECK-NEXT: vle64.v v24, (a5), v0.t
427 ; CHECK-NEXT: bltu a2, a3, .LBB32_6
428 ; CHECK-NEXT: # %bb.5:
429 ; CHECK-NEXT: li a2, 16
430 ; CHECK-NEXT: .LBB32_6:
431 ; CHECK-NEXT: vmv1r.v v0, v8
432 ; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma
433 ; CHECK-NEXT: vle64.v v8, (a1), v0.t
434 ; CHECK-NEXT: addi a1, a0, 128
435 ; CHECK-NEXT: addi a2, a0, 256
436 ; CHECK-NEXT: vsetivli zero, 16, e64, m8, ta, ma
437 ; CHECK-NEXT: vse64.v v8, (a0)
438 ; CHECK-NEXT: vse64.v v16, (a1)
439 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
440 ; CHECK-NEXT: vse64.v v24, (a2)
442 %load = call <33 x double> @llvm.vp.load.v33f64.p0(ptr %ptr, <33 x i1> %m, i32 %evl)
443 ret <33 x double> %load