1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v,+zfh,+zvfh,+f,+d -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s
7 define <2 x float> @vfwmul_v2f16(ptr %x, ptr %y) {
8 ; CHECK-LABEL: vfwmul_v2f16:
10 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
11 ; CHECK-NEXT: vle16.v v9, (a0)
12 ; CHECK-NEXT: vle16.v v10, (a1)
13 ; CHECK-NEXT: vfwmul.vv v8, v9, v10
15 %a = load <2 x half>, ptr %x
16 %b = load <2 x half>, ptr %y
17 %c = fpext <2 x half> %a to <2 x float>
18 %d = fpext <2 x half> %b to <2 x float>
19 %e = fmul <2 x float> %c, %d
23 define <4 x float> @vfwmul_v4f16(ptr %x, ptr %y) {
24 ; CHECK-LABEL: vfwmul_v4f16:
26 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
27 ; CHECK-NEXT: vle16.v v9, (a0)
28 ; CHECK-NEXT: vle16.v v10, (a1)
29 ; CHECK-NEXT: vfwmul.vv v8, v9, v10
31 %a = load <4 x half>, ptr %x
32 %b = load <4 x half>, ptr %y
33 %c = fpext <4 x half> %a to <4 x float>
34 %d = fpext <4 x half> %b to <4 x float>
35 %e = fmul <4 x float> %c, %d
39 define <8 x float> @vfwmul_v8f16(ptr %x, ptr %y) {
40 ; CHECK-LABEL: vfwmul_v8f16:
42 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
43 ; CHECK-NEXT: vle16.v v10, (a0)
44 ; CHECK-NEXT: vle16.v v11, (a1)
45 ; CHECK-NEXT: vfwmul.vv v8, v10, v11
47 %a = load <8 x half>, ptr %x
48 %b = load <8 x half>, ptr %y
49 %c = fpext <8 x half> %a to <8 x float>
50 %d = fpext <8 x half> %b to <8 x float>
51 %e = fmul <8 x float> %c, %d
55 define <16 x float> @vfwmul_v16f16(ptr %x, ptr %y) {
56 ; CHECK-LABEL: vfwmul_v16f16:
58 ; CHECK-NEXT: vsetivli zero, 16, e16, m2, ta, ma
59 ; CHECK-NEXT: vle16.v v12, (a0)
60 ; CHECK-NEXT: vle16.v v14, (a1)
61 ; CHECK-NEXT: vfwmul.vv v8, v12, v14
63 %a = load <16 x half>, ptr %x
64 %b = load <16 x half>, ptr %y
65 %c = fpext <16 x half> %a to <16 x float>
66 %d = fpext <16 x half> %b to <16 x float>
67 %e = fmul <16 x float> %c, %d
71 define <32 x float> @vfwmul_v32f16(ptr %x, ptr %y) {
72 ; CHECK-LABEL: vfwmul_v32f16:
74 ; CHECK-NEXT: li a2, 32
75 ; CHECK-NEXT: vsetvli zero, a2, e16, m4, ta, ma
76 ; CHECK-NEXT: vle16.v v16, (a0)
77 ; CHECK-NEXT: vle16.v v20, (a1)
78 ; CHECK-NEXT: vfwmul.vv v8, v16, v20
80 %a = load <32 x half>, ptr %x
81 %b = load <32 x half>, ptr %y
82 %c = fpext <32 x half> %a to <32 x float>
83 %d = fpext <32 x half> %b to <32 x float>
84 %e = fmul <32 x float> %c, %d
88 define <64 x float> @vfwmul_v64f16(ptr %x, ptr %y) {
89 ; CHECK-LABEL: vfwmul_v64f16:
91 ; CHECK-NEXT: addi sp, sp, -16
92 ; CHECK-NEXT: .cfi_def_cfa_offset 16
93 ; CHECK-NEXT: csrr a2, vlenb
94 ; CHECK-NEXT: slli a2, a2, 4
95 ; CHECK-NEXT: sub sp, sp, a2
96 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 16 * vlenb
97 ; CHECK-NEXT: li a2, 64
98 ; CHECK-NEXT: vsetvli zero, a2, e16, m8, ta, ma
99 ; CHECK-NEXT: vle16.v v8, (a0)
100 ; CHECK-NEXT: addi a0, sp, 16
101 ; CHECK-NEXT: vs8r.v v8, (a0) # Unknown-size Folded Spill
102 ; CHECK-NEXT: vle16.v v0, (a1)
103 ; CHECK-NEXT: li a0, 32
104 ; CHECK-NEXT: vsetvli zero, a0, e16, m8, ta, ma
105 ; CHECK-NEXT: vslidedown.vx v16, v8, a0
106 ; CHECK-NEXT: vslidedown.vx v8, v0, a0
107 ; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, ma
108 ; CHECK-NEXT: vmv4r.v v24, v8
109 ; CHECK-NEXT: vfwmul.vv v8, v16, v24
110 ; CHECK-NEXT: csrr a0, vlenb
111 ; CHECK-NEXT: slli a0, a0, 3
112 ; CHECK-NEXT: add a0, sp, a0
113 ; CHECK-NEXT: addi a0, a0, 16
114 ; CHECK-NEXT: vs8r.v v8, (a0) # Unknown-size Folded Spill
115 ; CHECK-NEXT: addi a0, sp, 16
116 ; CHECK-NEXT: vl8r.v v16, (a0) # Unknown-size Folded Reload
117 ; CHECK-NEXT: vfwmul.vv v8, v16, v0
118 ; CHECK-NEXT: csrr a0, vlenb
119 ; CHECK-NEXT: slli a0, a0, 3
120 ; CHECK-NEXT: add a0, sp, a0
121 ; CHECK-NEXT: addi a0, a0, 16
122 ; CHECK-NEXT: vl8r.v v16, (a0) # Unknown-size Folded Reload
123 ; CHECK-NEXT: csrr a0, vlenb
124 ; CHECK-NEXT: slli a0, a0, 4
125 ; CHECK-NEXT: add sp, sp, a0
126 ; CHECK-NEXT: addi sp, sp, 16
128 %a = load <64 x half>, ptr %x
129 %b = load <64 x half>, ptr %y
130 %c = fpext <64 x half> %a to <64 x float>
131 %d = fpext <64 x half> %b to <64 x float>
132 %e = fmul <64 x float> %c, %d
136 define <2 x double> @vfwmul_v2f32(ptr %x, ptr %y) {
137 ; CHECK-LABEL: vfwmul_v2f32:
139 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
140 ; CHECK-NEXT: vle32.v v9, (a0)
141 ; CHECK-NEXT: vle32.v v10, (a1)
142 ; CHECK-NEXT: vfwmul.vv v8, v9, v10
144 %a = load <2 x float>, ptr %x
145 %b = load <2 x float>, ptr %y
146 %c = fpext <2 x float> %a to <2 x double>
147 %d = fpext <2 x float> %b to <2 x double>
148 %e = fmul <2 x double> %c, %d
152 define <4 x double> @vfwmul_v4f32(ptr %x, ptr %y) {
153 ; CHECK-LABEL: vfwmul_v4f32:
155 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
156 ; CHECK-NEXT: vle32.v v10, (a0)
157 ; CHECK-NEXT: vle32.v v11, (a1)
158 ; CHECK-NEXT: vfwmul.vv v8, v10, v11
160 %a = load <4 x float>, ptr %x
161 %b = load <4 x float>, ptr %y
162 %c = fpext <4 x float> %a to <4 x double>
163 %d = fpext <4 x float> %b to <4 x double>
164 %e = fmul <4 x double> %c, %d
168 define <8 x double> @vfwmul_v8f32(ptr %x, ptr %y) {
169 ; CHECK-LABEL: vfwmul_v8f32:
171 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
172 ; CHECK-NEXT: vle32.v v12, (a0)
173 ; CHECK-NEXT: vle32.v v14, (a1)
174 ; CHECK-NEXT: vfwmul.vv v8, v12, v14
176 %a = load <8 x float>, ptr %x
177 %b = load <8 x float>, ptr %y
178 %c = fpext <8 x float> %a to <8 x double>
179 %d = fpext <8 x float> %b to <8 x double>
180 %e = fmul <8 x double> %c, %d
184 define <16 x double> @vfwmul_v16f32(ptr %x, ptr %y) {
185 ; CHECK-LABEL: vfwmul_v16f32:
187 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
188 ; CHECK-NEXT: vle32.v v16, (a0)
189 ; CHECK-NEXT: vle32.v v20, (a1)
190 ; CHECK-NEXT: vfwmul.vv v8, v16, v20
192 %a = load <16 x float>, ptr %x
193 %b = load <16 x float>, ptr %y
194 %c = fpext <16 x float> %a to <16 x double>
195 %d = fpext <16 x float> %b to <16 x double>
196 %e = fmul <16 x double> %c, %d
200 define <32 x double> @vfwmul_v32f32(ptr %x, ptr %y) {
201 ; CHECK-LABEL: vfwmul_v32f32:
203 ; CHECK-NEXT: addi sp, sp, -16
204 ; CHECK-NEXT: .cfi_def_cfa_offset 16
205 ; CHECK-NEXT: csrr a2, vlenb
206 ; CHECK-NEXT: slli a2, a2, 4
207 ; CHECK-NEXT: sub sp, sp, a2
208 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 16 * vlenb
209 ; CHECK-NEXT: li a2, 32
210 ; CHECK-NEXT: vsetvli zero, a2, e32, m8, ta, ma
211 ; CHECK-NEXT: vle32.v v8, (a0)
212 ; CHECK-NEXT: addi a0, sp, 16
213 ; CHECK-NEXT: vs8r.v v8, (a0) # Unknown-size Folded Spill
214 ; CHECK-NEXT: vle32.v v0, (a1)
215 ; CHECK-NEXT: vsetivli zero, 16, e32, m8, ta, ma
216 ; CHECK-NEXT: vslidedown.vi v16, v8, 16
217 ; CHECK-NEXT: vslidedown.vi v8, v0, 16
218 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
219 ; CHECK-NEXT: vmv4r.v v24, v8
220 ; CHECK-NEXT: vfwmul.vv v8, v16, v24
221 ; CHECK-NEXT: csrr a0, vlenb
222 ; CHECK-NEXT: slli a0, a0, 3
223 ; CHECK-NEXT: add a0, sp, a0
224 ; CHECK-NEXT: addi a0, a0, 16
225 ; CHECK-NEXT: vs8r.v v8, (a0) # Unknown-size Folded Spill
226 ; CHECK-NEXT: addi a0, sp, 16
227 ; CHECK-NEXT: vl8r.v v16, (a0) # Unknown-size Folded Reload
228 ; CHECK-NEXT: vfwmul.vv v8, v16, v0
229 ; CHECK-NEXT: csrr a0, vlenb
230 ; CHECK-NEXT: slli a0, a0, 3
231 ; CHECK-NEXT: add a0, sp, a0
232 ; CHECK-NEXT: addi a0, a0, 16
233 ; CHECK-NEXT: vl8r.v v16, (a0) # Unknown-size Folded Reload
234 ; CHECK-NEXT: csrr a0, vlenb
235 ; CHECK-NEXT: slli a0, a0, 4
236 ; CHECK-NEXT: add sp, sp, a0
237 ; CHECK-NEXT: addi sp, sp, 16
239 %a = load <32 x float>, ptr %x
240 %b = load <32 x float>, ptr %y
241 %c = fpext <32 x float> %a to <32 x double>
242 %d = fpext <32 x float> %b to <32 x double>
243 %e = fmul <32 x double> %c, %d
247 define <2 x float> @vfwmul_vf_v2f16(ptr %x, half %y) {
248 ; CHECK-LABEL: vfwmul_vf_v2f16:
250 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
251 ; CHECK-NEXT: vle16.v v9, (a0)
252 ; CHECK-NEXT: vfwmul.vf v8, v9, fa0
254 %a = load <2 x half>, ptr %x
255 %b = insertelement <2 x half> poison, half %y, i32 0
256 %c = shufflevector <2 x half> %b, <2 x half> poison, <2 x i32> zeroinitializer
257 %d = fpext <2 x half> %a to <2 x float>
258 %e = fpext <2 x half> %c to <2 x float>
259 %f = fmul <2 x float> %d, %e
263 define <4 x float> @vfwmul_vf_v4f16(ptr %x, half %y) {
264 ; CHECK-LABEL: vfwmul_vf_v4f16:
266 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
267 ; CHECK-NEXT: vle16.v v9, (a0)
268 ; CHECK-NEXT: vfwmul.vf v8, v9, fa0
270 %a = load <4 x half>, ptr %x
271 %b = insertelement <4 x half> poison, half %y, i32 0
272 %c = shufflevector <4 x half> %b, <4 x half> poison, <4 x i32> zeroinitializer
273 %d = fpext <4 x half> %a to <4 x float>
274 %e = fpext <4 x half> %c to <4 x float>
275 %f = fmul <4 x float> %d, %e
279 define <8 x float> @vfwmul_vf_v8f16(ptr %x, half %y) {
280 ; CHECK-LABEL: vfwmul_vf_v8f16:
282 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
283 ; CHECK-NEXT: vle16.v v10, (a0)
284 ; CHECK-NEXT: vfwmul.vf v8, v10, fa0
286 %a = load <8 x half>, ptr %x
287 %b = insertelement <8 x half> poison, half %y, i32 0
288 %c = shufflevector <8 x half> %b, <8 x half> poison, <8 x i32> zeroinitializer
289 %d = fpext <8 x half> %a to <8 x float>
290 %e = fpext <8 x half> %c to <8 x float>
291 %f = fmul <8 x float> %d, %e
295 define <16 x float> @vfwmul_vf_v16f16(ptr %x, half %y) {
296 ; CHECK-LABEL: vfwmul_vf_v16f16:
298 ; CHECK-NEXT: vsetivli zero, 16, e16, m2, ta, ma
299 ; CHECK-NEXT: vle16.v v12, (a0)
300 ; CHECK-NEXT: vfwmul.vf v8, v12, fa0
302 %a = load <16 x half>, ptr %x
303 %b = insertelement <16 x half> poison, half %y, i32 0
304 %c = shufflevector <16 x half> %b, <16 x half> poison, <16 x i32> zeroinitializer
305 %d = fpext <16 x half> %a to <16 x float>
306 %e = fpext <16 x half> %c to <16 x float>
307 %f = fmul <16 x float> %d, %e
311 define <32 x float> @vfwmul_vf_v32f16(ptr %x, half %y) {
312 ; CHECK-LABEL: vfwmul_vf_v32f16:
314 ; CHECK-NEXT: li a1, 32
315 ; CHECK-NEXT: vsetvli zero, a1, e16, m4, ta, ma
316 ; CHECK-NEXT: vle16.v v16, (a0)
317 ; CHECK-NEXT: vfwmul.vf v8, v16, fa0
319 %a = load <32 x half>, ptr %x
320 %b = insertelement <32 x half> poison, half %y, i32 0
321 %c = shufflevector <32 x half> %b, <32 x half> poison, <32 x i32> zeroinitializer
322 %d = fpext <32 x half> %a to <32 x float>
323 %e = fpext <32 x half> %c to <32 x float>
324 %f = fmul <32 x float> %d, %e
328 define <2 x double> @vfwmul_vf_v2f32(ptr %x, float %y) {
329 ; CHECK-LABEL: vfwmul_vf_v2f32:
331 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
332 ; CHECK-NEXT: vle32.v v9, (a0)
333 ; CHECK-NEXT: vfwmul.vf v8, v9, fa0
335 %a = load <2 x float>, ptr %x
336 %b = insertelement <2 x float> poison, float %y, i32 0
337 %c = shufflevector <2 x float> %b, <2 x float> poison, <2 x i32> zeroinitializer
338 %d = fpext <2 x float> %a to <2 x double>
339 %e = fpext <2 x float> %c to <2 x double>
340 %f = fmul <2 x double> %d, %e
344 define <4 x double> @vfwmul_vf_v4f32(ptr %x, float %y) {
345 ; CHECK-LABEL: vfwmul_vf_v4f32:
347 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
348 ; CHECK-NEXT: vle32.v v10, (a0)
349 ; CHECK-NEXT: vfwmul.vf v8, v10, fa0
351 %a = load <4 x float>, ptr %x
352 %b = insertelement <4 x float> poison, float %y, i32 0
353 %c = shufflevector <4 x float> %b, <4 x float> poison, <4 x i32> zeroinitializer
354 %d = fpext <4 x float> %a to <4 x double>
355 %e = fpext <4 x float> %c to <4 x double>
356 %f = fmul <4 x double> %d, %e
360 define <8 x double> @vfwmul_vf_v8f32(ptr %x, float %y) {
361 ; CHECK-LABEL: vfwmul_vf_v8f32:
363 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
364 ; CHECK-NEXT: vle32.v v12, (a0)
365 ; CHECK-NEXT: vfwmul.vf v8, v12, fa0
367 %a = load <8 x float>, ptr %x
368 %b = insertelement <8 x float> poison, float %y, i32 0
369 %c = shufflevector <8 x float> %b, <8 x float> poison, <8 x i32> zeroinitializer
370 %d = fpext <8 x float> %a to <8 x double>
371 %e = fpext <8 x float> %c to <8 x double>
372 %f = fmul <8 x double> %d, %e
376 define <16 x double> @vfwmul_vf_v16f32(ptr %x, float %y) {
377 ; CHECK-LABEL: vfwmul_vf_v16f32:
379 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
380 ; CHECK-NEXT: vle32.v v16, (a0)
381 ; CHECK-NEXT: vfwmul.vf v8, v16, fa0
383 %a = load <16 x float>, ptr %x
384 %b = insertelement <16 x float> poison, float %y, i32 0
385 %c = shufflevector <16 x float> %b, <16 x float> poison, <16 x i32> zeroinitializer
386 %d = fpext <16 x float> %a to <16 x double>
387 %e = fpext <16 x float> %c to <16 x double>
388 %f = fmul <16 x double> %d, %e
392 define <32 x double> @vfwmul_vf_v32f32(ptr %x, float %y) {
393 ; CHECK-LABEL: vfwmul_vf_v32f32:
395 ; CHECK-NEXT: li a1, 32
396 ; CHECK-NEXT: vsetvli zero, a1, e32, m8, ta, ma
397 ; CHECK-NEXT: vle32.v v16, (a0)
398 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
399 ; CHECK-NEXT: vfwcvt.f.f.v v8, v16
400 ; CHECK-NEXT: vsetivli zero, 16, e32, m8, ta, ma
401 ; CHECK-NEXT: vslidedown.vi v16, v16, 16
402 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
403 ; CHECK-NEXT: vfwcvt.f.f.v v24, v16
404 ; CHECK-NEXT: vfmv.v.f v16, fa0
405 ; CHECK-NEXT: vfwcvt.f.f.v v0, v16
406 ; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma
407 ; CHECK-NEXT: vfmul.vv v16, v24, v0
408 ; CHECK-NEXT: vfmul.vv v8, v8, v0
410 %a = load <32 x float>, ptr %x
411 %b = insertelement <32 x float> poison, float %y, i32 0
412 %c = shufflevector <32 x float> %b, <32 x float> poison, <32 x i32> zeroinitializer
413 %d = fpext <32 x float> %a to <32 x double>
414 %e = fpext <32 x float> %c to <32 x double>
415 %f = fmul <32 x double> %d, %e
419 define <2 x float> @vfwmul_squared_v2f16_v2f32(ptr %x) {
420 ; CHECK-LABEL: vfwmul_squared_v2f16_v2f32:
422 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
423 ; CHECK-NEXT: vle16.v v9, (a0)
424 ; CHECK-NEXT: vfwmul.vv v8, v9, v9
426 %a = load <2 x half>, ptr %x
427 %b = fpext <2 x half> %a to <2 x float>
428 %c = fmul <2 x float> %b, %b
432 define <2 x double> @vfwmul_squared_v2f32_v2f64(ptr %x) {
433 ; CHECK-LABEL: vfwmul_squared_v2f32_v2f64:
435 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
436 ; CHECK-NEXT: vle32.v v9, (a0)
437 ; CHECK-NEXT: vfwmul.vv v8, v9, v9
439 %a = load <2 x float>, ptr %x
440 %b = fpext <2 x float> %a to <2 x double>
441 %c = fmul <2 x double> %b, %b
445 define <2 x double> @vfwmul_squared_v2f16_v2f64(ptr %x) {
446 ; CHECK-LABEL: vfwmul_squared_v2f16_v2f64:
448 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
449 ; CHECK-NEXT: vle16.v v8, (a0)
450 ; CHECK-NEXT: vfwcvt.f.f.v v9, v8
451 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
452 ; CHECK-NEXT: vfwmul.vv v8, v9, v9
454 %a = load <2 x half>, ptr %x
455 %b = fpext <2 x half> %a to <2 x double>
456 %c = fmul <2 x double> %b, %b