1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+m,+d,+v,+zfbfmin,+zvfbfmin -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+m,+d,+v,+zfbfmin,+zvfbfmin -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s
6 ; RUN: llc -mtriple=riscv32 -mattr=+m,+d,+v,+zvfh,+zfbfmin,+zvfbfmin -target-abi=ilp32d \
7 ; RUN: -verify-machineinstrs < %s | FileCheck %s
8 ; RUN: llc -mtriple=riscv64 -mattr=+m,+d,+v,+zvfh,+zfbfmin,+zvfbfmin -target-abi=lp64d \
9 ; RUN: -verify-machineinstrs < %s | FileCheck %s
11 define <vscale x 1 x bfloat> @vfmerge_vv_nxv1bf16(<vscale x 1 x bfloat> %va, <vscale x 1 x bfloat> %vb, <vscale x 1 x i1> %cond) {
12 ; CHECK-LABEL: vfmerge_vv_nxv1bf16:
14 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
15 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
17 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x bfloat> %va, <vscale x 1 x bfloat> %vb
18 ret <vscale x 1 x bfloat> %vc
21 define <vscale x 1 x bfloat> @vfmerge_fv_nxv1bf16(<vscale x 1 x bfloat> %va, bfloat %b, <vscale x 1 x i1> %cond) {
22 ; CHECK-LABEL: vfmerge_fv_nxv1bf16:
24 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
25 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
26 ; CHECK-NEXT: vfmv.v.f v9, fa5
27 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
28 ; CHECK-NEXT: vfncvtbf16.f.f.w v8, v9, v0.t
30 %head = insertelement <vscale x 1 x bfloat> poison, bfloat %b, i32 0
31 %splat = shufflevector <vscale x 1 x bfloat> %head, <vscale x 1 x bfloat> poison, <vscale x 1 x i32> zeroinitializer
32 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x bfloat> %splat, <vscale x 1 x bfloat> %va
33 ret <vscale x 1 x bfloat> %vc
36 define <vscale x 2 x bfloat> @vfmerge_vv_nxv2bf16(<vscale x 2 x bfloat> %va, <vscale x 2 x bfloat> %vb, <vscale x 2 x i1> %cond) {
37 ; CHECK-LABEL: vfmerge_vv_nxv2bf16:
39 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
40 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
42 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x bfloat> %va, <vscale x 2 x bfloat> %vb
43 ret <vscale x 2 x bfloat> %vc
46 define <vscale x 2 x bfloat> @vfmerge_fv_nxv2bf16(<vscale x 2 x bfloat> %va, bfloat %b, <vscale x 2 x i1> %cond) {
47 ; CHECK-LABEL: vfmerge_fv_nxv2bf16:
49 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
50 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
51 ; CHECK-NEXT: vfmv.v.f v9, fa5
52 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
53 ; CHECK-NEXT: vfncvtbf16.f.f.w v8, v9, v0.t
55 %head = insertelement <vscale x 2 x bfloat> poison, bfloat %b, i32 0
56 %splat = shufflevector <vscale x 2 x bfloat> %head, <vscale x 2 x bfloat> poison, <vscale x 2 x i32> zeroinitializer
57 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x bfloat> %splat, <vscale x 2 x bfloat> %va
58 ret <vscale x 2 x bfloat> %vc
61 define <vscale x 4 x bfloat> @vfmerge_vv_nxv4bf16(<vscale x 4 x bfloat> %va, <vscale x 4 x bfloat> %vb, <vscale x 4 x i1> %cond) {
62 ; CHECK-LABEL: vfmerge_vv_nxv4bf16:
64 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
65 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
67 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x bfloat> %va, <vscale x 4 x bfloat> %vb
68 ret <vscale x 4 x bfloat> %vc
71 define <vscale x 4 x bfloat> @vfmerge_fv_nxv4bf16(<vscale x 4 x bfloat> %va, bfloat %b, <vscale x 4 x i1> %cond) {
72 ; CHECK-LABEL: vfmerge_fv_nxv4bf16:
74 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
75 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
76 ; CHECK-NEXT: vfmv.v.f v10, fa5
77 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu
78 ; CHECK-NEXT: vfncvtbf16.f.f.w v8, v10, v0.t
80 %head = insertelement <vscale x 4 x bfloat> poison, bfloat %b, i32 0
81 %splat = shufflevector <vscale x 4 x bfloat> %head, <vscale x 4 x bfloat> poison, <vscale x 4 x i32> zeroinitializer
82 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x bfloat> %splat, <vscale x 4 x bfloat> %va
83 ret <vscale x 4 x bfloat> %vc
86 define <vscale x 8 x bfloat> @vfmerge_vv_nxv8bf16(<vscale x 8 x bfloat> %va, <vscale x 8 x bfloat> %vb, <vscale x 8 x i1> %cond) {
87 ; CHECK-LABEL: vfmerge_vv_nxv8bf16:
89 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
90 ; CHECK-NEXT: vmerge.vvm v8, v10, v8, v0
92 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x bfloat> %va, <vscale x 8 x bfloat> %vb
93 ret <vscale x 8 x bfloat> %vc
96 define <vscale x 8 x bfloat> @vfmerge_fv_nxv8bf16(<vscale x 8 x bfloat> %va, bfloat %b, <vscale x 8 x i1> %cond) {
97 ; CHECK-LABEL: vfmerge_fv_nxv8bf16:
99 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
100 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
101 ; CHECK-NEXT: vfmv.v.f v12, fa5
102 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu
103 ; CHECK-NEXT: vfncvtbf16.f.f.w v8, v12, v0.t
105 %head = insertelement <vscale x 8 x bfloat> poison, bfloat %b, i32 0
106 %splat = shufflevector <vscale x 8 x bfloat> %head, <vscale x 8 x bfloat> poison, <vscale x 8 x i32> zeroinitializer
107 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x bfloat> %splat, <vscale x 8 x bfloat> %va
108 ret <vscale x 8 x bfloat> %vc
111 define <vscale x 8 x bfloat> @vfmerge_zv_nxv8bf16(<vscale x 8 x bfloat> %va, <vscale x 8 x i1> %cond) {
112 ; CHECK-LABEL: vfmerge_zv_nxv8bf16:
114 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
115 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
117 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x bfloat> splat (bfloat zeroinitializer), <vscale x 8 x bfloat> %va
118 ret <vscale x 8 x bfloat> %vc
121 define <vscale x 8 x bfloat> @vmerge_truelhs_nxv8bf16_0(<vscale x 8 x bfloat> %va, <vscale x 8 x bfloat> %vb) {
122 ; CHECK-LABEL: vmerge_truelhs_nxv8bf16_0:
125 %vc = select <vscale x 8 x i1> splat (i1 1), <vscale x 8 x bfloat> %va, <vscale x 8 x bfloat> %vb
126 ret <vscale x 8 x bfloat> %vc
129 define <vscale x 8 x bfloat> @vmerge_falselhs_nxv8bf16_0(<vscale x 8 x bfloat> %va, <vscale x 8 x bfloat> %vb) {
130 ; CHECK-LABEL: vmerge_falselhs_nxv8bf16_0:
132 ; CHECK-NEXT: vmv2r.v v8, v10
134 %vc = select <vscale x 8 x i1> zeroinitializer, <vscale x 8 x bfloat> %va, <vscale x 8 x bfloat> %vb
135 ret <vscale x 8 x bfloat> %vc
138 define <vscale x 16 x bfloat> @vfmerge_vv_nxv16bf16(<vscale x 16 x bfloat> %va, <vscale x 16 x bfloat> %vb, <vscale x 16 x i1> %cond) {
139 ; CHECK-LABEL: vfmerge_vv_nxv16bf16:
141 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
142 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
144 %vc = select <vscale x 16 x i1> %cond, <vscale x 16 x bfloat> %va, <vscale x 16 x bfloat> %vb
145 ret <vscale x 16 x bfloat> %vc
148 define <vscale x 16 x bfloat> @vfmerge_fv_nxv16bf16(<vscale x 16 x bfloat> %va, bfloat %b, <vscale x 16 x i1> %cond) {
149 ; CHECK-LABEL: vfmerge_fv_nxv16bf16:
151 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
152 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
153 ; CHECK-NEXT: vfmv.v.f v16, fa5
154 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu
155 ; CHECK-NEXT: vfncvtbf16.f.f.w v8, v16, v0.t
157 %head = insertelement <vscale x 16 x bfloat> poison, bfloat %b, i32 0
158 %splat = shufflevector <vscale x 16 x bfloat> %head, <vscale x 16 x bfloat> poison, <vscale x 16 x i32> zeroinitializer
159 %vc = select <vscale x 16 x i1> %cond, <vscale x 16 x bfloat> %splat, <vscale x 16 x bfloat> %va
160 ret <vscale x 16 x bfloat> %vc
163 define <vscale x 32 x bfloat> @vfmerge_vv_nxv32bf16(<vscale x 32 x bfloat> %va, <vscale x 32 x bfloat> %vb, <vscale x 32 x i1> %cond) {
164 ; CHECK-LABEL: vfmerge_vv_nxv32bf16:
166 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
167 ; CHECK-NEXT: vmerge.vvm v8, v16, v8, v0
169 %vc = select <vscale x 32 x i1> %cond, <vscale x 32 x bfloat> %va, <vscale x 32 x bfloat> %vb
170 ret <vscale x 32 x bfloat> %vc
173 define <vscale x 32 x bfloat> @vfmerge_fv_nxv32bf16(<vscale x 32 x bfloat> %va, bfloat %b, <vscale x 32 x i1> %cond) {
174 ; CHECK-LABEL: vfmerge_fv_nxv32bf16:
176 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
177 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
178 ; CHECK-NEXT: vfmv.v.f v16, fa5
179 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, ma
180 ; CHECK-NEXT: vfncvtbf16.f.f.w v24, v16
181 ; CHECK-NEXT: vmv.v.v v28, v24
182 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
183 ; CHECK-NEXT: vmerge.vvm v8, v8, v24, v0
185 %head = insertelement <vscale x 32 x bfloat> poison, bfloat %b, i32 0
186 %splat = shufflevector <vscale x 32 x bfloat> %head, <vscale x 32 x bfloat> poison, <vscale x 32 x i32> zeroinitializer
187 %vc = select <vscale x 32 x i1> %cond, <vscale x 32 x bfloat> %splat, <vscale x 32 x bfloat> %va
188 ret <vscale x 32 x bfloat> %vc