1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+m,+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32,CHECK-ZVFH
4 ; RUN: llc -mtriple=riscv64 -mattr=+m,+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64,CHECK-ZVFH
6 ; RUN: llc -mtriple=riscv32 -mattr=+m,+d,+zfh,+zvfhmin,+v -target-abi=ilp32d \
7 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32,CHECK-ZVFHMIN
8 ; RUN: llc -mtriple=riscv64 -mattr=+m,+d,+zfh,+zvfhmin,+v -target-abi=lp64d \
9 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64,CHECK-ZVFHMIN
11 define <vscale x 1 x half> @vfmerge_vv_nxv1f16(<vscale x 1 x half> %va, <vscale x 1 x half> %vb, <vscale x 1 x i1> %cond) {
12 ; CHECK-LABEL: vfmerge_vv_nxv1f16:
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 half> %va, <vscale x 1 x half> %vb
18 ret <vscale x 1 x half> %vc
21 define <vscale x 1 x half> @vfmerge_fv_nxv1f16(<vscale x 1 x half> %va, half %b, <vscale x 1 x i1> %cond) {
22 ; CHECK-ZVFH-LABEL: vfmerge_fv_nxv1f16:
23 ; CHECK-ZVFH: # %bb.0:
24 ; CHECK-ZVFH-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
25 ; CHECK-ZVFH-NEXT: vfmerge.vfm v8, v8, fa0, v0
26 ; CHECK-ZVFH-NEXT: ret
28 ; CHECK-ZVFHMIN-LABEL: vfmerge_fv_nxv1f16:
29 ; CHECK-ZVFHMIN: # %bb.0:
30 ; CHECK-ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
31 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
32 ; CHECK-ZVFHMIN-NEXT: vfmv.v.f v9, fa5
33 ; CHECK-ZVFHMIN-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
34 ; CHECK-ZVFHMIN-NEXT: vfncvt.f.f.w v8, v9, v0.t
35 ; CHECK-ZVFHMIN-NEXT: ret
36 %head = insertelement <vscale x 1 x half> poison, half %b, i32 0
37 %splat = shufflevector <vscale x 1 x half> %head, <vscale x 1 x half> poison, <vscale x 1 x i32> zeroinitializer
38 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x half> %splat, <vscale x 1 x half> %va
39 ret <vscale x 1 x half> %vc
42 define <vscale x 2 x half> @vfmerge_vv_nxv2f16(<vscale x 2 x half> %va, <vscale x 2 x half> %vb, <vscale x 2 x i1> %cond) {
43 ; CHECK-LABEL: vfmerge_vv_nxv2f16:
45 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
46 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
48 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x half> %va, <vscale x 2 x half> %vb
49 ret <vscale x 2 x half> %vc
52 define <vscale x 2 x half> @vfmerge_fv_nxv2f16(<vscale x 2 x half> %va, half %b, <vscale x 2 x i1> %cond) {
53 ; CHECK-ZVFH-LABEL: vfmerge_fv_nxv2f16:
54 ; CHECK-ZVFH: # %bb.0:
55 ; CHECK-ZVFH-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
56 ; CHECK-ZVFH-NEXT: vfmerge.vfm v8, v8, fa0, v0
57 ; CHECK-ZVFH-NEXT: ret
59 ; CHECK-ZVFHMIN-LABEL: vfmerge_fv_nxv2f16:
60 ; CHECK-ZVFHMIN: # %bb.0:
61 ; CHECK-ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
62 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e32, m1, ta, ma
63 ; CHECK-ZVFHMIN-NEXT: vfmv.v.f v9, fa5
64 ; CHECK-ZVFHMIN-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
65 ; CHECK-ZVFHMIN-NEXT: vfncvt.f.f.w v8, v9, v0.t
66 ; CHECK-ZVFHMIN-NEXT: ret
67 %head = insertelement <vscale x 2 x half> poison, half %b, i32 0
68 %splat = shufflevector <vscale x 2 x half> %head, <vscale x 2 x half> poison, <vscale x 2 x i32> zeroinitializer
69 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x half> %splat, <vscale x 2 x half> %va
70 ret <vscale x 2 x half> %vc
73 define <vscale x 4 x half> @vfmerge_vv_nxv4f16(<vscale x 4 x half> %va, <vscale x 4 x half> %vb, <vscale x 4 x i1> %cond) {
74 ; CHECK-LABEL: vfmerge_vv_nxv4f16:
76 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
77 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
79 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x half> %va, <vscale x 4 x half> %vb
80 ret <vscale x 4 x half> %vc
83 define <vscale x 4 x half> @vfmerge_fv_nxv4f16(<vscale x 4 x half> %va, half %b, <vscale x 4 x i1> %cond) {
84 ; CHECK-ZVFH-LABEL: vfmerge_fv_nxv4f16:
85 ; CHECK-ZVFH: # %bb.0:
86 ; CHECK-ZVFH-NEXT: vsetvli a0, zero, e16, m1, ta, ma
87 ; CHECK-ZVFH-NEXT: vfmerge.vfm v8, v8, fa0, v0
88 ; CHECK-ZVFH-NEXT: ret
90 ; CHECK-ZVFHMIN-LABEL: vfmerge_fv_nxv4f16:
91 ; CHECK-ZVFHMIN: # %bb.0:
92 ; CHECK-ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
93 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e32, m2, ta, ma
94 ; CHECK-ZVFHMIN-NEXT: vfmv.v.f v10, fa5
95 ; CHECK-ZVFHMIN-NEXT: vsetvli zero, zero, e16, m1, ta, mu
96 ; CHECK-ZVFHMIN-NEXT: vfncvt.f.f.w v8, v10, v0.t
97 ; CHECK-ZVFHMIN-NEXT: ret
98 %head = insertelement <vscale x 4 x half> poison, half %b, i32 0
99 %splat = shufflevector <vscale x 4 x half> %head, <vscale x 4 x half> poison, <vscale x 4 x i32> zeroinitializer
100 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x half> %splat, <vscale x 4 x half> %va
101 ret <vscale x 4 x half> %vc
104 define <vscale x 8 x half> @vfmerge_vv_nxv8f16(<vscale x 8 x half> %va, <vscale x 8 x half> %vb, <vscale x 8 x i1> %cond) {
105 ; CHECK-LABEL: vfmerge_vv_nxv8f16:
107 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
108 ; CHECK-NEXT: vmerge.vvm v8, v10, v8, v0
110 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x half> %va, <vscale x 8 x half> %vb
111 ret <vscale x 8 x half> %vc
114 define <vscale x 8 x half> @vfmerge_fv_nxv8f16(<vscale x 8 x half> %va, half %b, <vscale x 8 x i1> %cond) {
115 ; CHECK-ZVFH-LABEL: vfmerge_fv_nxv8f16:
116 ; CHECK-ZVFH: # %bb.0:
117 ; CHECK-ZVFH-NEXT: vsetvli a0, zero, e16, m2, ta, ma
118 ; CHECK-ZVFH-NEXT: vfmerge.vfm v8, v8, fa0, v0
119 ; CHECK-ZVFH-NEXT: ret
121 ; CHECK-ZVFHMIN-LABEL: vfmerge_fv_nxv8f16:
122 ; CHECK-ZVFHMIN: # %bb.0:
123 ; CHECK-ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
124 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e32, m4, ta, ma
125 ; CHECK-ZVFHMIN-NEXT: vfmv.v.f v12, fa5
126 ; CHECK-ZVFHMIN-NEXT: vsetvli zero, zero, e16, m2, ta, mu
127 ; CHECK-ZVFHMIN-NEXT: vfncvt.f.f.w v8, v12, v0.t
128 ; CHECK-ZVFHMIN-NEXT: ret
129 %head = insertelement <vscale x 8 x half> poison, half %b, i32 0
130 %splat = shufflevector <vscale x 8 x half> %head, <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
131 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x half> %splat, <vscale x 8 x half> %va
132 ret <vscale x 8 x half> %vc
135 define <vscale x 8 x half> @vfmerge_zv_nxv8f16(<vscale x 8 x half> %va, <vscale x 8 x i1> %cond) {
136 ; CHECK-LABEL: vfmerge_zv_nxv8f16:
138 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
139 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
141 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x half> splat (half zeroinitializer), <vscale x 8 x half> %va
142 ret <vscale x 8 x half> %vc
145 define <vscale x 8 x half> @vfmerge_nzv_nxv8f16(<vscale x 8 x half> %va, <vscale x 8 x i1> %cond) {
146 ; CHECK-LABEL: vfmerge_nzv_nxv8f16:
148 ; CHECK-NEXT: lui a0, 1048568
149 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
150 ; CHECK-NEXT: vmerge.vxm v8, v8, a0, v0
152 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x half> splat (half -0.0), <vscale x 8 x half> %va
153 ret <vscale x 8 x half> %vc
156 define <vscale x 8 x half> @vmerge_truelhs_nxv8f16_0(<vscale x 8 x half> %va, <vscale x 8 x half> %vb) {
157 ; CHECK-LABEL: vmerge_truelhs_nxv8f16_0:
160 %vc = select <vscale x 8 x i1> splat (i1 1), <vscale x 8 x half> %va, <vscale x 8 x half> %vb
161 ret <vscale x 8 x half> %vc
164 define <vscale x 8 x half> @vmerge_falselhs_nxv8f16_0(<vscale x 8 x half> %va, <vscale x 8 x half> %vb) {
165 ; CHECK-LABEL: vmerge_falselhs_nxv8f16_0:
167 ; CHECK-NEXT: vmv2r.v v8, v10
169 %vc = select <vscale x 8 x i1> zeroinitializer, <vscale x 8 x half> %va, <vscale x 8 x half> %vb
170 ret <vscale x 8 x half> %vc
173 define <vscale x 16 x half> @vfmerge_vv_nxv16f16(<vscale x 16 x half> %va, <vscale x 16 x half> %vb, <vscale x 16 x i1> %cond) {
174 ; CHECK-LABEL: vfmerge_vv_nxv16f16:
176 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
177 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
179 %vc = select <vscale x 16 x i1> %cond, <vscale x 16 x half> %va, <vscale x 16 x half> %vb
180 ret <vscale x 16 x half> %vc
183 define <vscale x 16 x half> @vfmerge_fv_nxv16f16(<vscale x 16 x half> %va, half %b, <vscale x 16 x i1> %cond) {
184 ; CHECK-ZVFH-LABEL: vfmerge_fv_nxv16f16:
185 ; CHECK-ZVFH: # %bb.0:
186 ; CHECK-ZVFH-NEXT: vsetvli a0, zero, e16, m4, ta, ma
187 ; CHECK-ZVFH-NEXT: vfmerge.vfm v8, v8, fa0, v0
188 ; CHECK-ZVFH-NEXT: ret
190 ; CHECK-ZVFHMIN-LABEL: vfmerge_fv_nxv16f16:
191 ; CHECK-ZVFHMIN: # %bb.0:
192 ; CHECK-ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
193 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e32, m8, ta, ma
194 ; CHECK-ZVFHMIN-NEXT: vfmv.v.f v16, fa5
195 ; CHECK-ZVFHMIN-NEXT: vsetvli zero, zero, e16, m4, ta, mu
196 ; CHECK-ZVFHMIN-NEXT: vfncvt.f.f.w v8, v16, v0.t
197 ; CHECK-ZVFHMIN-NEXT: ret
198 %head = insertelement <vscale x 16 x half> poison, half %b, i32 0
199 %splat = shufflevector <vscale x 16 x half> %head, <vscale x 16 x half> poison, <vscale x 16 x i32> zeroinitializer
200 %vc = select <vscale x 16 x i1> %cond, <vscale x 16 x half> %splat, <vscale x 16 x half> %va
201 ret <vscale x 16 x half> %vc
204 define <vscale x 32 x half> @vfmerge_vv_nxv32f16(<vscale x 32 x half> %va, <vscale x 32 x half> %vb, <vscale x 32 x i1> %cond) {
205 ; CHECK-LABEL: vfmerge_vv_nxv32f16:
207 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
208 ; CHECK-NEXT: vmerge.vvm v8, v16, v8, v0
210 %vc = select <vscale x 32 x i1> %cond, <vscale x 32 x half> %va, <vscale x 32 x half> %vb
211 ret <vscale x 32 x half> %vc
214 define <vscale x 32 x half> @vfmerge_fv_nxv32f16(<vscale x 32 x half> %va, half %b, <vscale x 32 x i1> %cond) {
215 ; CHECK-ZVFH-LABEL: vfmerge_fv_nxv32f16:
216 ; CHECK-ZVFH: # %bb.0:
217 ; CHECK-ZVFH-NEXT: vsetvli a0, zero, e16, m8, ta, ma
218 ; CHECK-ZVFH-NEXT: vfmerge.vfm v8, v8, fa0, v0
219 ; CHECK-ZVFH-NEXT: ret
221 ; CHECK-ZVFHMIN-LABEL: vfmerge_fv_nxv32f16:
222 ; CHECK-ZVFHMIN: # %bb.0:
223 ; CHECK-ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
224 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e32, m8, ta, ma
225 ; CHECK-ZVFHMIN-NEXT: vfmv.v.f v16, fa5
226 ; CHECK-ZVFHMIN-NEXT: vsetvli zero, zero, e16, m4, ta, ma
227 ; CHECK-ZVFHMIN-NEXT: vfncvt.f.f.w v24, v16
228 ; CHECK-ZVFHMIN-NEXT: vmv.v.v v28, v24
229 ; CHECK-ZVFHMIN-NEXT: vsetvli a0, zero, e16, m8, ta, ma
230 ; CHECK-ZVFHMIN-NEXT: vmerge.vvm v8, v8, v24, v0
231 ; CHECK-ZVFHMIN-NEXT: ret
232 %head = insertelement <vscale x 32 x half> poison, half %b, i32 0
233 %splat = shufflevector <vscale x 32 x half> %head, <vscale x 32 x half> poison, <vscale x 32 x i32> zeroinitializer
234 %vc = select <vscale x 32 x i1> %cond, <vscale x 32 x half> %splat, <vscale x 32 x half> %va
235 ret <vscale x 32 x half> %vc
238 define <vscale x 1 x float> @vfmerge_vv_nxv1f32(<vscale x 1 x float> %va, <vscale x 1 x float> %vb, <vscale x 1 x i1> %cond) {
239 ; CHECK-LABEL: vfmerge_vv_nxv1f32:
241 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
242 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
244 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x float> %va, <vscale x 1 x float> %vb
245 ret <vscale x 1 x float> %vc
248 define <vscale x 1 x float> @vfmerge_fv_nxv1f32(<vscale x 1 x float> %va, float %b, <vscale x 1 x i1> %cond) {
249 ; CHECK-LABEL: vfmerge_fv_nxv1f32:
251 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
252 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
254 %head = insertelement <vscale x 1 x float> poison, float %b, i32 0
255 %splat = shufflevector <vscale x 1 x float> %head, <vscale x 1 x float> poison, <vscale x 1 x i32> zeroinitializer
256 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x float> %splat, <vscale x 1 x float> %va
257 ret <vscale x 1 x float> %vc
260 define <vscale x 2 x float> @vfmerge_vv_nxv2f32(<vscale x 2 x float> %va, <vscale x 2 x float> %vb, <vscale x 2 x i1> %cond) {
261 ; CHECK-LABEL: vfmerge_vv_nxv2f32:
263 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
264 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
266 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x float> %va, <vscale x 2 x float> %vb
267 ret <vscale x 2 x float> %vc
270 define <vscale x 2 x float> @vfmerge_fv_nxv2f32(<vscale x 2 x float> %va, float %b, <vscale x 2 x i1> %cond) {
271 ; CHECK-LABEL: vfmerge_fv_nxv2f32:
273 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
274 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
276 %head = insertelement <vscale x 2 x float> poison, float %b, i32 0
277 %splat = shufflevector <vscale x 2 x float> %head, <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
278 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x float> %splat, <vscale x 2 x float> %va
279 ret <vscale x 2 x float> %vc
282 define <vscale x 4 x float> @vfmerge_vv_nxv4f32(<vscale x 4 x float> %va, <vscale x 4 x float> %vb, <vscale x 4 x i1> %cond) {
283 ; CHECK-LABEL: vfmerge_vv_nxv4f32:
285 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
286 ; CHECK-NEXT: vmerge.vvm v8, v10, v8, v0
288 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x float> %va, <vscale x 4 x float> %vb
289 ret <vscale x 4 x float> %vc
292 define <vscale x 4 x float> @vfmerge_fv_nxv4f32(<vscale x 4 x float> %va, float %b, <vscale x 4 x i1> %cond) {
293 ; CHECK-LABEL: vfmerge_fv_nxv4f32:
295 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
296 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
298 %head = insertelement <vscale x 4 x float> poison, float %b, i32 0
299 %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
300 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x float> %splat, <vscale x 4 x float> %va
301 ret <vscale x 4 x float> %vc
304 define <vscale x 8 x float> @vfmerge_vv_nxv8f32(<vscale x 8 x float> %va, <vscale x 8 x float> %vb, <vscale x 8 x i1> %cond) {
305 ; CHECK-LABEL: vfmerge_vv_nxv8f32:
307 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
308 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
310 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x float> %va, <vscale x 8 x float> %vb
311 ret <vscale x 8 x float> %vc
314 define <vscale x 8 x float> @vfmerge_fv_nxv8f32(<vscale x 8 x float> %va, float %b, <vscale x 8 x i1> %cond) {
315 ; CHECK-LABEL: vfmerge_fv_nxv8f32:
317 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
318 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
320 %head = insertelement <vscale x 8 x float> poison, float %b, i32 0
321 %splat = shufflevector <vscale x 8 x float> %head, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
322 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x float> %splat, <vscale x 8 x float> %va
323 ret <vscale x 8 x float> %vc
326 define <vscale x 8 x float> @vfmerge_zv_nxv8f32(<vscale x 8 x float> %va, <vscale x 8 x i1> %cond) {
327 ; CHECK-LABEL: vfmerge_zv_nxv8f32:
329 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
330 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
332 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x float> splat (float zeroinitializer), <vscale x 8 x float> %va
333 ret <vscale x 8 x float> %vc
336 define <vscale x 8 x float> @vfmerge_nzv_nxv8f32(<vscale x 8 x float> %va, <vscale x 8 x i1> %cond) {
337 ; CHECK-LABEL: vfmerge_nzv_nxv8f32:
339 ; CHECK-NEXT: lui a0, 524288
340 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
341 ; CHECK-NEXT: vmerge.vxm v8, v8, a0, v0
343 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x float> splat (float -0.0), <vscale x 8 x float> %va
344 ret <vscale x 8 x float> %vc
347 define <vscale x 16 x float> @vfmerge_vv_nxv16f32(<vscale x 16 x float> %va, <vscale x 16 x float> %vb, <vscale x 16 x i1> %cond) {
348 ; CHECK-LABEL: vfmerge_vv_nxv16f32:
350 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
351 ; CHECK-NEXT: vmerge.vvm v8, v16, v8, v0
353 %vc = select <vscale x 16 x i1> %cond, <vscale x 16 x float> %va, <vscale x 16 x float> %vb
354 ret <vscale x 16 x float> %vc
357 define <vscale x 16 x float> @vfmerge_fv_nxv16f32(<vscale x 16 x float> %va, float %b, <vscale x 16 x i1> %cond) {
358 ; CHECK-LABEL: vfmerge_fv_nxv16f32:
360 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
361 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
363 %head = insertelement <vscale x 16 x float> poison, float %b, i32 0
364 %splat = shufflevector <vscale x 16 x float> %head, <vscale x 16 x float> poison, <vscale x 16 x i32> zeroinitializer
365 %vc = select <vscale x 16 x i1> %cond, <vscale x 16 x float> %splat, <vscale x 16 x float> %va
366 ret <vscale x 16 x float> %vc
369 define <vscale x 1 x double> @vfmerge_vv_nxv1f64(<vscale x 1 x double> %va, <vscale x 1 x double> %vb, <vscale x 1 x i1> %cond) {
370 ; CHECK-LABEL: vfmerge_vv_nxv1f64:
372 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
373 ; CHECK-NEXT: vmerge.vvm v8, v9, v8, v0
375 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x double> %va, <vscale x 1 x double> %vb
376 ret <vscale x 1 x double> %vc
379 define <vscale x 1 x double> @vfmerge_fv_nxv1f64(<vscale x 1 x double> %va, double %b, <vscale x 1 x i1> %cond) {
380 ; CHECK-LABEL: vfmerge_fv_nxv1f64:
382 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
383 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
385 %head = insertelement <vscale x 1 x double> poison, double %b, i32 0
386 %splat = shufflevector <vscale x 1 x double> %head, <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer
387 %vc = select <vscale x 1 x i1> %cond, <vscale x 1 x double> %splat, <vscale x 1 x double> %va
388 ret <vscale x 1 x double> %vc
391 define <vscale x 2 x double> @vfmerge_vv_nxv2f64(<vscale x 2 x double> %va, <vscale x 2 x double> %vb, <vscale x 2 x i1> %cond) {
392 ; CHECK-LABEL: vfmerge_vv_nxv2f64:
394 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
395 ; CHECK-NEXT: vmerge.vvm v8, v10, v8, v0
397 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x double> %va, <vscale x 2 x double> %vb
398 ret <vscale x 2 x double> %vc
401 define <vscale x 2 x double> @vfmerge_fv_nxv2f64(<vscale x 2 x double> %va, double %b, <vscale x 2 x i1> %cond) {
402 ; CHECK-LABEL: vfmerge_fv_nxv2f64:
404 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
405 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
407 %head = insertelement <vscale x 2 x double> poison, double %b, i32 0
408 %splat = shufflevector <vscale x 2 x double> %head, <vscale x 2 x double> poison, <vscale x 2 x i32> zeroinitializer
409 %vc = select <vscale x 2 x i1> %cond, <vscale x 2 x double> %splat, <vscale x 2 x double> %va
410 ret <vscale x 2 x double> %vc
413 define <vscale x 4 x double> @vfmerge_vv_nxv4f64(<vscale x 4 x double> %va, <vscale x 4 x double> %vb, <vscale x 4 x i1> %cond) {
414 ; CHECK-LABEL: vfmerge_vv_nxv4f64:
416 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
417 ; CHECK-NEXT: vmerge.vvm v8, v12, v8, v0
419 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x double> %va, <vscale x 4 x double> %vb
420 ret <vscale x 4 x double> %vc
423 define <vscale x 4 x double> @vfmerge_fv_nxv4f64(<vscale x 4 x double> %va, double %b, <vscale x 4 x i1> %cond) {
424 ; CHECK-LABEL: vfmerge_fv_nxv4f64:
426 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
427 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
429 %head = insertelement <vscale x 4 x double> poison, double %b, i32 0
430 %splat = shufflevector <vscale x 4 x double> %head, <vscale x 4 x double> poison, <vscale x 4 x i32> zeroinitializer
431 %vc = select <vscale x 4 x i1> %cond, <vscale x 4 x double> %splat, <vscale x 4 x double> %va
432 ret <vscale x 4 x double> %vc
435 define <vscale x 8 x double> @vfmerge_vv_nxv8f64(<vscale x 8 x double> %va, <vscale x 8 x double> %vb, <vscale x 8 x i1> %cond) {
436 ; CHECK-LABEL: vfmerge_vv_nxv8f64:
438 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
439 ; CHECK-NEXT: vmerge.vvm v8, v16, v8, v0
441 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x double> %va, <vscale x 8 x double> %vb
442 ret <vscale x 8 x double> %vc
445 define <vscale x 8 x double> @vfmerge_fv_nxv8f64(<vscale x 8 x double> %va, double %b, <vscale x 8 x i1> %cond) {
446 ; CHECK-LABEL: vfmerge_fv_nxv8f64:
448 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
449 ; CHECK-NEXT: vfmerge.vfm v8, v8, fa0, v0
451 %head = insertelement <vscale x 8 x double> poison, double %b, i32 0
452 %splat = shufflevector <vscale x 8 x double> %head, <vscale x 8 x double> poison, <vscale x 8 x i32> zeroinitializer
453 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x double> %splat, <vscale x 8 x double> %va
454 ret <vscale x 8 x double> %vc
457 define <vscale x 8 x double> @vfmerge_zv_nxv8f64(<vscale x 8 x double> %va, <vscale x 8 x i1> %cond) {
458 ; CHECK-LABEL: vfmerge_zv_nxv8f64:
460 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
461 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
463 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x double> splat (double zeroinitializer), <vscale x 8 x double> %va
464 ret <vscale x 8 x double> %vc
467 define <vscale x 8 x double> @vfmerge_nzv_nxv8f64(<vscale x 8 x double> %va, <vscale x 8 x i1> %cond) {
468 ; RV32-LABEL: vfmerge_nzv_nxv8f64:
470 ; RV32-NEXT: fcvt.d.w fa5, zero
471 ; RV32-NEXT: fneg.d fa5, fa5
472 ; RV32-NEXT: vsetvli a0, zero, e64, m8, ta, ma
473 ; RV32-NEXT: vfmerge.vfm v8, v8, fa5, v0
476 ; RV64-LABEL: vfmerge_nzv_nxv8f64:
478 ; RV64-NEXT: li a0, -1
479 ; RV64-NEXT: slli a0, a0, 63
480 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
481 ; RV64-NEXT: vmerge.vxm v8, v8, a0, v0
483 %vc = select <vscale x 8 x i1> %cond, <vscale x 8 x double> splat (double -0.0), <vscale x 8 x double> %va
484 ret <vscale x 8 x double> %vc
487 define <vscale x 16 x double> @vselect_combine_regression(<vscale x 16 x i64> %va, <vscale x 16 x double> %vb) {
488 ; CHECK-LABEL: vselect_combine_regression:
490 ; CHECK-NEXT: addi sp, sp, -16
491 ; CHECK-NEXT: .cfi_def_cfa_offset 16
492 ; CHECK-NEXT: csrr a1, vlenb
493 ; CHECK-NEXT: slli a1, a1, 4
494 ; CHECK-NEXT: sub sp, sp, a1
495 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 16 * vlenb
496 ; CHECK-NEXT: addi a1, sp, 16
497 ; CHECK-NEXT: vs8r.v v8, (a1) # Unknown-size Folded Spill
498 ; CHECK-NEXT: csrr a1, vlenb
499 ; CHECK-NEXT: slli a1, a1, 3
500 ; CHECK-NEXT: add a1, a0, a1
501 ; CHECK-NEXT: vl8re64.v v8, (a1)
502 ; CHECK-NEXT: csrr a1, vlenb
503 ; CHECK-NEXT: slli a1, a1, 3
504 ; CHECK-NEXT: add a1, sp, a1
505 ; CHECK-NEXT: addi a1, a1, 16
506 ; CHECK-NEXT: vs8r.v v8, (a1) # Unknown-size Folded Spill
507 ; CHECK-NEXT: vl8re64.v v8, (a0)
508 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
509 ; CHECK-NEXT: vmseq.vi v24, v16, 0
510 ; CHECK-NEXT: addi a0, sp, 16
511 ; CHECK-NEXT: vl8r.v v16, (a0) # Unknown-size Folded Reload
512 ; CHECK-NEXT: vmseq.vi v0, v16, 0
513 ; CHECK-NEXT: vmv.v.i v16, 0
514 ; CHECK-NEXT: vmerge.vvm v8, v16, v8, v0
515 ; CHECK-NEXT: vmv1r.v v0, v24
516 ; CHECK-NEXT: csrr a0, vlenb
517 ; CHECK-NEXT: slli a0, a0, 3
518 ; CHECK-NEXT: add a0, sp, a0
519 ; CHECK-NEXT: addi a0, a0, 16
520 ; CHECK-NEXT: vl8r.v v24, (a0) # Unknown-size Folded Reload
521 ; CHECK-NEXT: vmerge.vvm v16, v16, v24, v0
522 ; CHECK-NEXT: csrr a0, vlenb
523 ; CHECK-NEXT: slli a0, a0, 4
524 ; CHECK-NEXT: add sp, sp, a0
525 ; CHECK-NEXT: addi sp, sp, 16
527 %cond = icmp eq <vscale x 16 x i64> %va, zeroinitializer
528 %sel = select <vscale x 16 x i1> %cond, <vscale x 16 x double> %vb, <vscale x 16 x double> zeroinitializer
529 ret <vscale x 16 x double> %sel
532 define void @vselect_legalize_regression(<vscale x 16 x double> %a, <vscale x 16 x i1> %ma, <vscale x 16 x i1> %mb, ptr %out) {
533 ; CHECK-LABEL: vselect_legalize_regression:
535 ; CHECK-NEXT: vsetvli a2, zero, e8, m2, ta, ma
536 ; CHECK-NEXT: vlm.v v24, (a0)
537 ; CHECK-NEXT: vmand.mm v7, v0, v24
538 ; CHECK-NEXT: csrr a0, vlenb
539 ; CHECK-NEXT: srli a2, a0, 3
540 ; CHECK-NEXT: vsetvli a3, zero, e8, mf4, ta, ma
541 ; CHECK-NEXT: vslidedown.vx v0, v7, a2
542 ; CHECK-NEXT: vsetvli a2, zero, e64, m8, ta, ma
543 ; CHECK-NEXT: vmv.v.i v24, 0
544 ; CHECK-NEXT: vmerge.vvm v16, v24, v16, v0
545 ; CHECK-NEXT: vmv1r.v v0, v7
546 ; CHECK-NEXT: vmerge.vvm v8, v24, v8, v0
547 ; CHECK-NEXT: vs8r.v v8, (a1)
548 ; CHECK-NEXT: slli a0, a0, 3
549 ; CHECK-NEXT: add a0, a1, a0
550 ; CHECK-NEXT: vs8r.v v16, (a0)
552 %cond = and <vscale x 16 x i1> %ma, %mb
553 %sel = select <vscale x 16 x i1> %cond, <vscale x 16 x double> %a, <vscale x 16 x double> zeroinitializer
554 store <vscale x 16 x double> %sel, ptr %out