1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfhmin,+v -verify-machineinstrs < %s | FileCheck %s
5 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfhmin,+v -verify-machineinstrs < %s | FileCheck %s
8 declare <2 x half> @llvm.vp.fptrunc.v2f16.v2f32(<2 x float>, <2 x i1>, i32)
10 define <2 x half> @vfptrunc_v2f16_v2f32(<2 x float> %a, <2 x i1> %m, i32 zeroext %vl) {
11 ; CHECK-LABEL: vfptrunc_v2f16_v2f32:
13 ; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
14 ; CHECK-NEXT: vfncvt.f.f.w v9, v8, v0.t
15 ; CHECK-NEXT: vmv1r.v v8, v9
17 %v = call <2 x half> @llvm.vp.fptrunc.v2f16.v2f32(<2 x float> %a, <2 x i1> %m, i32 %vl)
21 define <2 x half> @vfptrunc_v2f16_v2f32_unmasked(<2 x float> %a, i32 zeroext %vl) {
22 ; CHECK-LABEL: vfptrunc_v2f16_v2f32_unmasked:
24 ; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
25 ; CHECK-NEXT: vfncvt.f.f.w v9, v8
26 ; CHECK-NEXT: vmv1r.v v8, v9
28 %v = call <2 x half> @llvm.vp.fptrunc.v2f16.v2f32(<2 x float> %a, <2 x i1> shufflevector (<2 x i1> insertelement (<2 x i1> undef, i1 true, i32 0), <2 x i1> undef, <2 x i32> zeroinitializer), i32 %vl)
32 declare <2 x half> @llvm.vp.fptrunc.v2f16.v2f64(<2 x double>, <2 x i1>, i32)
34 define <2 x half> @vfptrunc_v2f16_v2f64(<2 x double> %a, <2 x i1> %m, i32 zeroext %vl) {
35 ; CHECK-LABEL: vfptrunc_v2f16_v2f64:
37 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
38 ; CHECK-NEXT: vfncvt.rod.f.f.w v9, v8, v0.t
39 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
40 ; CHECK-NEXT: vfncvt.f.f.w v8, v9, v0.t
42 %v = call <2 x half> @llvm.vp.fptrunc.v2f16.v2f64(<2 x double> %a, <2 x i1> %m, i32 %vl)
46 define <2 x half> @vfptrunc_v2f16_v2f64_unmasked(<2 x double> %a, i32 zeroext %vl) {
47 ; CHECK-LABEL: vfptrunc_v2f16_v2f64_unmasked:
49 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
50 ; CHECK-NEXT: vfncvt.rod.f.f.w v9, v8
51 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
52 ; CHECK-NEXT: vfncvt.f.f.w v8, v9
54 %v = call <2 x half> @llvm.vp.fptrunc.v2f16.v2f64(<2 x double> %a, <2 x i1> shufflevector (<2 x i1> insertelement (<2 x i1> undef, i1 true, i32 0), <2 x i1> undef, <2 x i32> zeroinitializer), i32 %vl)
58 declare <2 x float> @llvm.vp.fptrunc.v2f64.v2f32(<2 x double>, <2 x i1>, i32)
60 define <2 x float> @vfptrunc_v2f32_v2f64(<2 x double> %a, <2 x i1> %m, i32 zeroext %vl) {
61 ; CHECK-LABEL: vfptrunc_v2f32_v2f64:
63 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
64 ; CHECK-NEXT: vfncvt.f.f.w v9, v8, v0.t
65 ; CHECK-NEXT: vmv1r.v v8, v9
67 %v = call <2 x float> @llvm.vp.fptrunc.v2f64.v2f32(<2 x double> %a, <2 x i1> %m, i32 %vl)
71 define <2 x float> @vfptrunc_v2f32_v2f64_unmasked(<2 x double> %a, i32 zeroext %vl) {
72 ; CHECK-LABEL: vfptrunc_v2f32_v2f64_unmasked:
74 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
75 ; CHECK-NEXT: vfncvt.f.f.w v9, v8
76 ; CHECK-NEXT: vmv1r.v v8, v9
78 %v = call <2 x float> @llvm.vp.fptrunc.v2f64.v2f32(<2 x double> %a, <2 x i1> shufflevector (<2 x i1> insertelement (<2 x i1> undef, i1 true, i32 0), <2 x i1> undef, <2 x i32> zeroinitializer), i32 %vl)
82 declare <15 x float> @llvm.vp.fptrunc.v15f64.v15f32(<15 x double>, <15 x i1>, i32)
84 define <15 x float> @vfptrunc_v15f32_v15f64(<15 x double> %a, <15 x i1> %m, i32 zeroext %vl) {
85 ; CHECK-LABEL: vfptrunc_v15f32_v15f64:
87 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
88 ; CHECK-NEXT: vfncvt.f.f.w v16, v8, v0.t
89 ; CHECK-NEXT: vmv.v.v v8, v16
91 %v = call <15 x float> @llvm.vp.fptrunc.v15f64.v15f32(<15 x double> %a, <15 x i1> %m, i32 %vl)
95 declare <32 x float> @llvm.vp.fptrunc.v32f64.v32f32(<32 x double>, <32 x i1>, i32)
97 define <32 x float> @vfptrunc_v32f32_v32f64(<32 x double> %a, <32 x i1> %m, i32 zeroext %vl) {
98 ; CHECK-LABEL: vfptrunc_v32f32_v32f64:
100 ; CHECK-NEXT: vmv8r.v v24, v8
101 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
102 ; CHECK-NEXT: li a2, 16
103 ; CHECK-NEXT: vslidedown.vi v12, v0, 2
104 ; CHECK-NEXT: mv a1, a0
105 ; CHECK-NEXT: bltu a0, a2, .LBB7_2
106 ; CHECK-NEXT: # %bb.1:
107 ; CHECK-NEXT: li a1, 16
108 ; CHECK-NEXT: .LBB7_2:
109 ; CHECK-NEXT: vsetvli zero, a1, e32, m4, ta, ma
110 ; CHECK-NEXT: vfncvt.f.f.w v8, v24, v0.t
111 ; CHECK-NEXT: addi a1, a0, -16
112 ; CHECK-NEXT: sltu a0, a0, a1
113 ; CHECK-NEXT: addi a0, a0, -1
114 ; CHECK-NEXT: and a0, a0, a1
115 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
116 ; CHECK-NEXT: vmv1r.v v0, v12
117 ; CHECK-NEXT: vfncvt.f.f.w v24, v16, v0.t
118 ; CHECK-NEXT: li a0, 32
119 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
120 ; CHECK-NEXT: vslideup.vi v8, v24, 16
122 %v = call <32 x float> @llvm.vp.fptrunc.v32f64.v32f32(<32 x double> %a, <32 x i1> %m, i32 %vl)