1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+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 %a = insertelement <4 x i1> poison, i1 true, i32 0
50 %b = shufflevector <4 x i1> %a, <4 x i1> poison, <4 x i32> zeroinitializer
51 %load = call <4 x i8> @llvm.vp.load.v4i8.p0(ptr %ptr, <4 x i1> %b, i32 %evl)
55 declare <8 x i8> @llvm.vp.load.v8i8.p0(ptr, <8 x i1>, i32)
57 define <8 x i8> @vpload_v8i8(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
58 ; CHECK-LABEL: vpload_v8i8:
60 ; CHECK-NEXT: vsetvli zero, a1, e8, mf2, ta, ma
61 ; CHECK-NEXT: vle8.v v8, (a0), v0.t
63 %load = call <8 x i8> @llvm.vp.load.v8i8.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
67 declare <2 x i16> @llvm.vp.load.v2i16.p0(ptr, <2 x i1>, i32)
69 define <2 x i16> @vpload_v2i16(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
70 ; CHECK-LABEL: vpload_v2i16:
72 ; CHECK-NEXT: vsetvli zero, a1, e16, mf4, ta, ma
73 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
75 %load = call <2 x i16> @llvm.vp.load.v2i16.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
79 declare <4 x i16> @llvm.vp.load.v4i16.p0(ptr, <4 x i1>, i32)
81 define <4 x i16> @vpload_v4i16(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
82 ; CHECK-LABEL: vpload_v4i16:
84 ; CHECK-NEXT: vsetvli zero, a1, e16, mf2, ta, ma
85 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
87 %load = call <4 x i16> @llvm.vp.load.v4i16.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
91 declare <8 x i16> @llvm.vp.load.v8i16.p0(ptr, <8 x i1>, i32)
93 define <8 x i16> @vpload_v8i16(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
94 ; CHECK-LABEL: vpload_v8i16:
96 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
97 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
99 %load = call <8 x i16> @llvm.vp.load.v8i16.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
103 define <8 x i16> @vpload_v8i16_allones_mask(ptr %ptr, i32 zeroext %evl) {
104 ; CHECK-LABEL: vpload_v8i16_allones_mask:
106 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
107 ; CHECK-NEXT: vle16.v v8, (a0)
109 %a = insertelement <8 x i1> poison, i1 true, i32 0
110 %b = shufflevector <8 x i1> %a, <8 x i1> poison, <8 x i32> zeroinitializer
111 %load = call <8 x i16> @llvm.vp.load.v8i16.p0(ptr %ptr, <8 x i1> %b, i32 %evl)
115 declare <2 x i32> @llvm.vp.load.v2i32.p0(ptr, <2 x i1>, i32)
117 define <2 x i32> @vpload_v2i32(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
118 ; CHECK-LABEL: vpload_v2i32:
120 ; CHECK-NEXT: vsetvli zero, a1, e32, mf2, ta, ma
121 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
123 %load = call <2 x i32> @llvm.vp.load.v2i32.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
127 declare <4 x i32> @llvm.vp.load.v4i32.p0(ptr, <4 x i1>, i32)
129 define <4 x i32> @vpload_v4i32(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
130 ; CHECK-LABEL: vpload_v4i32:
132 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma
133 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
135 %load = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
139 declare <6 x i32> @llvm.vp.load.v6i32.p0(ptr, <6 x i1>, i32)
141 define <6 x i32> @vpload_v6i32(ptr %ptr, <6 x i1> %m, i32 zeroext %evl) {
142 ; CHECK-LABEL: vpload_v6i32:
144 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
145 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
147 %load = call <6 x i32> @llvm.vp.load.v6i32.p0(ptr %ptr, <6 x i1> %m, i32 %evl)
151 define <6 x i32> @vpload_v6i32_allones_mask(ptr %ptr, i32 zeroext %evl) {
152 ; CHECK-LABEL: vpload_v6i32_allones_mask:
154 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
155 ; CHECK-NEXT: vle32.v v8, (a0)
157 %a = insertelement <6 x i1> poison, i1 true, i32 0
158 %b = shufflevector <6 x i1> %a, <6 x i1> poison, <6 x i32> zeroinitializer
159 %load = call <6 x i32> @llvm.vp.load.v6i32.p0(ptr %ptr, <6 x i1> %b, i32 %evl)
163 declare <8 x i32> @llvm.vp.load.v8i32.p0(ptr, <8 x i1>, i32)
165 define <8 x i32> @vpload_v8i32(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
166 ; CHECK-LABEL: vpload_v8i32:
168 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
169 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
171 %load = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
175 define <8 x i32> @vpload_v8i32_allones_mask(ptr %ptr, i32 zeroext %evl) {
176 ; CHECK-LABEL: vpload_v8i32_allones_mask:
178 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
179 ; CHECK-NEXT: vle32.v v8, (a0)
181 %a = insertelement <8 x i1> poison, i1 true, i32 0
182 %b = shufflevector <8 x i1> %a, <8 x i1> poison, <8 x i32> zeroinitializer
183 %load = call <8 x i32> @llvm.vp.load.v8i32.p0(ptr %ptr, <8 x i1> %b, i32 %evl)
187 declare <2 x i64> @llvm.vp.load.v2i64.p0(ptr, <2 x i1>, i32)
189 define <2 x i64> @vpload_v2i64(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
190 ; CHECK-LABEL: vpload_v2i64:
192 ; CHECK-NEXT: vsetvli zero, a1, e64, m1, ta, ma
193 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
195 %load = call <2 x i64> @llvm.vp.load.v2i64.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
199 declare <4 x i64> @llvm.vp.load.v4i64.p0(ptr, <4 x i1>, i32)
201 define <4 x i64> @vpload_v4i64(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
202 ; CHECK-LABEL: vpload_v4i64:
204 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
205 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
207 %load = call <4 x i64> @llvm.vp.load.v4i64.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
211 define <4 x i64> @vpload_v4i64_allones_mask(ptr %ptr, i32 zeroext %evl) {
212 ; CHECK-LABEL: vpload_v4i64_allones_mask:
214 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
215 ; CHECK-NEXT: vle64.v v8, (a0)
217 %a = insertelement <4 x i1> poison, i1 true, i32 0
218 %b = shufflevector <4 x i1> %a, <4 x i1> poison, <4 x i32> zeroinitializer
219 %load = call <4 x i64> @llvm.vp.load.v4i64.p0(ptr %ptr, <4 x i1> %b, i32 %evl)
223 declare <8 x i64> @llvm.vp.load.v8i64.p0(ptr, <8 x i1>, i32)
225 define <8 x i64> @vpload_v8i64(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
226 ; CHECK-LABEL: vpload_v8i64:
228 ; CHECK-NEXT: vsetvli zero, a1, e64, m4, ta, ma
229 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
231 %load = call <8 x i64> @llvm.vp.load.v8i64.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
235 declare <2 x half> @llvm.vp.load.v2f16.p0(ptr, <2 x i1>, i32)
237 define <2 x half> @vpload_v2f16(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
238 ; CHECK-LABEL: vpload_v2f16:
240 ; CHECK-NEXT: vsetvli zero, a1, e16, mf4, ta, ma
241 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
243 %load = call <2 x half> @llvm.vp.load.v2f16.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
247 define <2 x half> @vpload_v2f16_allones_mask(ptr %ptr, i32 zeroext %evl) {
248 ; CHECK-LABEL: vpload_v2f16_allones_mask:
250 ; CHECK-NEXT: vsetvli zero, a1, e16, mf4, ta, ma
251 ; CHECK-NEXT: vle16.v v8, (a0)
253 %a = insertelement <2 x i1> poison, i1 true, i32 0
254 %b = shufflevector <2 x i1> %a, <2 x i1> poison, <2 x i32> zeroinitializer
255 %load = call <2 x half> @llvm.vp.load.v2f16.p0(ptr %ptr, <2 x i1> %b, i32 %evl)
259 declare <4 x half> @llvm.vp.load.v4f16.p0(ptr, <4 x i1>, i32)
261 define <4 x half> @vpload_v4f16(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
262 ; CHECK-LABEL: vpload_v4f16:
264 ; CHECK-NEXT: vsetvli zero, a1, e16, mf2, ta, ma
265 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
267 %load = call <4 x half> @llvm.vp.load.v4f16.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
271 declare <8 x half> @llvm.vp.load.v8f16.p0(ptr, <8 x i1>, i32)
273 define <8 x half> @vpload_v8f16(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
274 ; CHECK-LABEL: vpload_v8f16:
276 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
277 ; CHECK-NEXT: vle16.v v8, (a0), v0.t
279 %load = call <8 x half> @llvm.vp.load.v8f16.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
283 declare <2 x float> @llvm.vp.load.v2f32.p0(ptr, <2 x i1>, i32)
285 define <2 x float> @vpload_v2f32(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
286 ; CHECK-LABEL: vpload_v2f32:
288 ; CHECK-NEXT: vsetvli zero, a1, e32, mf2, ta, ma
289 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
291 %load = call <2 x float> @llvm.vp.load.v2f32.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
292 ret <2 x float> %load
295 declare <4 x float> @llvm.vp.load.v4f32.p0(ptr, <4 x i1>, i32)
297 define <4 x float> @vpload_v4f32(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
298 ; CHECK-LABEL: vpload_v4f32:
300 ; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma
301 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
303 %load = call <4 x float> @llvm.vp.load.v4f32.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
304 ret <4 x float> %load
307 declare <8 x float> @llvm.vp.load.v8f32.p0(ptr, <8 x i1>, i32)
309 define <8 x float> @vpload_v8f32(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
310 ; CHECK-LABEL: vpload_v8f32:
312 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
313 ; CHECK-NEXT: vle32.v v8, (a0), v0.t
315 %load = call <8 x float> @llvm.vp.load.v8f32.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
316 ret <8 x float> %load
319 define <8 x float> @vpload_v8f32_allones_mask(ptr %ptr, i32 zeroext %evl) {
320 ; CHECK-LABEL: vpload_v8f32_allones_mask:
322 ; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma
323 ; CHECK-NEXT: vle32.v v8, (a0)
325 %a = insertelement <8 x i1> poison, i1 true, i32 0
326 %b = shufflevector <8 x i1> %a, <8 x i1> poison, <8 x i32> zeroinitializer
327 %load = call <8 x float> @llvm.vp.load.v8f32.p0(ptr %ptr, <8 x i1> %b, i32 %evl)
328 ret <8 x float> %load
331 declare <2 x double> @llvm.vp.load.v2f64.p0(ptr, <2 x i1>, i32)
333 define <2 x double> @vpload_v2f64(ptr %ptr, <2 x i1> %m, i32 zeroext %evl) {
334 ; CHECK-LABEL: vpload_v2f64:
336 ; CHECK-NEXT: vsetvli zero, a1, e64, m1, ta, ma
337 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
339 %load = call <2 x double> @llvm.vp.load.v2f64.p0(ptr %ptr, <2 x i1> %m, i32 %evl)
340 ret <2 x double> %load
343 declare <4 x double> @llvm.vp.load.v4f64.p0(ptr, <4 x i1>, i32)
345 define <4 x double> @vpload_v4f64(ptr %ptr, <4 x i1> %m, i32 zeroext %evl) {
346 ; CHECK-LABEL: vpload_v4f64:
348 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
349 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
351 %load = call <4 x double> @llvm.vp.load.v4f64.p0(ptr %ptr, <4 x i1> %m, i32 %evl)
352 ret <4 x double> %load
355 define <4 x double> @vpload_v4f64_allones_mask(ptr %ptr, i32 zeroext %evl) {
356 ; CHECK-LABEL: vpload_v4f64_allones_mask:
358 ; CHECK-NEXT: vsetvli zero, a1, e64, m2, ta, ma
359 ; CHECK-NEXT: vle64.v v8, (a0)
361 %a = insertelement <4 x i1> poison, i1 true, i32 0
362 %b = shufflevector <4 x i1> %a, <4 x i1> poison, <4 x i32> zeroinitializer
363 %load = call <4 x double> @llvm.vp.load.v4f64.p0(ptr %ptr, <4 x i1> %b, i32 %evl)
364 ret <4 x double> %load
367 declare <8 x double> @llvm.vp.load.v8f64.p0(ptr, <8 x i1>, i32)
369 define <8 x double> @vpload_v8f64(ptr %ptr, <8 x i1> %m, i32 zeroext %evl) {
370 ; CHECK-LABEL: vpload_v8f64:
372 ; CHECK-NEXT: vsetvli zero, a1, e64, m4, ta, ma
373 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
375 %load = call <8 x double> @llvm.vp.load.v8f64.p0(ptr %ptr, <8 x i1> %m, i32 %evl)
376 ret <8 x double> %load
379 declare <32 x double> @llvm.vp.load.v32f64.p0(ptr, <32 x i1>, i32)
381 define <32 x double> @vpload_v32f64(ptr %ptr, <32 x i1> %m, i32 zeroext %evl) {
382 ; CHECK-LABEL: vpload_v32f64:
384 ; CHECK-NEXT: li a3, 16
385 ; CHECK-NEXT: mv a2, a1
386 ; CHECK-NEXT: bltu a1, a3, .LBB31_2
387 ; CHECK-NEXT: # %bb.1:
388 ; CHECK-NEXT: li a2, 16
389 ; CHECK-NEXT: .LBB31_2:
390 ; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma
391 ; CHECK-NEXT: vle64.v v8, (a0), v0.t
392 ; CHECK-NEXT: addi a2, a1, -16
393 ; CHECK-NEXT: sltu a1, a1, a2
394 ; CHECK-NEXT: addi a1, a1, -1
395 ; CHECK-NEXT: and a1, a1, a2
396 ; CHECK-NEXT: addi a0, a0, 128
397 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
398 ; CHECK-NEXT: vslidedown.vi v0, v0, 2
399 ; CHECK-NEXT: vsetvli zero, a1, e64, m8, ta, ma
400 ; CHECK-NEXT: vle64.v v16, (a0), v0.t
402 %load = call <32 x double> @llvm.vp.load.v32f64.p0(ptr %ptr, <32 x i1> %m, i32 %evl)
403 ret <32 x double> %load
406 declare <33 x double> @llvm.vp.load.v33f64.p0(ptr, <33 x i1>, i32)
408 ; Widen to v64f64 then split into 4 x v16f64, of which 1 is empty.
410 define <33 x double> @vpload_v33f64(ptr %ptr, <33 x i1> %m, i32 zeroext %evl) {
411 ; CHECK-LABEL: vpload_v33f64:
413 ; CHECK-NEXT: li a4, 32
414 ; CHECK-NEXT: vmv1r.v v8, v0
415 ; CHECK-NEXT: mv a3, a2
416 ; CHECK-NEXT: bltu a2, a4, .LBB32_2
417 ; CHECK-NEXT: # %bb.1:
418 ; CHECK-NEXT: li a3, 32
419 ; CHECK-NEXT: .LBB32_2:
420 ; CHECK-NEXT: addi a4, a3, -16
421 ; CHECK-NEXT: sltu a5, a3, a4
422 ; CHECK-NEXT: addi a5, a5, -1
423 ; CHECK-NEXT: and a4, a5, a4
424 ; CHECK-NEXT: addi a5, a1, 128
425 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
426 ; CHECK-NEXT: vslidedown.vi v0, v8, 2
427 ; CHECK-NEXT: vsetvli zero, a4, e64, m8, ta, ma
428 ; CHECK-NEXT: vle64.v v16, (a5), v0.t
429 ; CHECK-NEXT: addi a4, a2, -32
430 ; CHECK-NEXT: sltu a2, a2, a4
431 ; CHECK-NEXT: addi a2, a2, -1
432 ; CHECK-NEXT: and a4, a2, a4
433 ; CHECK-NEXT: li a2, 16
434 ; CHECK-NEXT: bltu a4, a2, .LBB32_4
435 ; CHECK-NEXT: # %bb.3:
436 ; CHECK-NEXT: li a4, 16
437 ; CHECK-NEXT: .LBB32_4:
438 ; CHECK-NEXT: addi a5, a1, 256
439 ; CHECK-NEXT: vsetivli zero, 4, e8, mf2, ta, ma
440 ; CHECK-NEXT: vslidedown.vi v0, v8, 4
441 ; CHECK-NEXT: vsetvli zero, a4, e64, m8, ta, ma
442 ; CHECK-NEXT: vle64.v v24, (a5), v0.t
443 ; CHECK-NEXT: bltu a3, a2, .LBB32_6
444 ; CHECK-NEXT: # %bb.5:
445 ; CHECK-NEXT: li a3, 16
446 ; CHECK-NEXT: .LBB32_6:
447 ; CHECK-NEXT: vsetvli zero, a3, e64, m8, ta, ma
448 ; CHECK-NEXT: vmv1r.v v0, v8
449 ; CHECK-NEXT: vle64.v v8, (a1), v0.t
450 ; CHECK-NEXT: vsetivli zero, 16, e64, m8, ta, ma
451 ; CHECK-NEXT: vse64.v v8, (a0)
452 ; CHECK-NEXT: addi a1, a0, 128
453 ; CHECK-NEXT: vse64.v v16, (a1)
454 ; CHECK-NEXT: addi a0, a0, 256
455 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
456 ; CHECK-NEXT: vse64.v v24, (a0)
458 %load = call <33 x double> @llvm.vp.load.v33f64.p0(ptr %ptr, <33 x i1> %m, i32 %evl)
459 ret <33 x double> %load