1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=1 | FileCheck %s --check-prefixes=NO_FOLDING
3 ; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=2 | FileCheck %s --check-prefixes=NO_FOLDING
4 ; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=3 | FileCheck %s --check-prefixes=FOLDING
5 ; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfhmin,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=3 | FileCheck %s --check-prefixes=FOLDING,ZVFHMIN
6 ; Check that the default value enables the web folding and
7 ; that it is bigger than 3.
8 ; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=FOLDING
10 define void @vfwmul_v2f116_multiple_users(ptr %x, ptr %y, ptr %z, <2 x half> %a, <2 x half> %b, <2 x half> %b2) {
11 ; NO_FOLDING-LABEL: vfwmul_v2f116_multiple_users:
12 ; NO_FOLDING: # %bb.0:
13 ; NO_FOLDING-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
14 ; NO_FOLDING-NEXT: vfwcvt.f.f.v v11, v8
15 ; NO_FOLDING-NEXT: vfwcvt.f.f.v v8, v9
16 ; NO_FOLDING-NEXT: vfwcvt.f.f.v v9, v10
17 ; NO_FOLDING-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
18 ; NO_FOLDING-NEXT: vfmul.vv v10, v11, v8
19 ; NO_FOLDING-NEXT: vfadd.vv v11, v11, v9
20 ; NO_FOLDING-NEXT: vfsub.vv v8, v8, v9
21 ; NO_FOLDING-NEXT: vse32.v v10, (a0)
22 ; NO_FOLDING-NEXT: vse32.v v11, (a1)
23 ; NO_FOLDING-NEXT: vse32.v v8, (a2)
24 ; NO_FOLDING-NEXT: ret
26 ; ZVFHMIN-LABEL: vfwmul_v2f116_multiple_users:
28 ; ZVFHMIN-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
29 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v11, v8
30 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v8, v9
31 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v9, v10
32 ; ZVFHMIN-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
33 ; ZVFHMIN-NEXT: vfmul.vv v10, v11, v8
34 ; ZVFHMIN-NEXT: vfadd.vv v11, v11, v9
35 ; ZVFHMIN-NEXT: vfsub.vv v8, v8, v9
36 ; ZVFHMIN-NEXT: vse32.v v10, (a0)
37 ; ZVFHMIN-NEXT: vse32.v v11, (a1)
38 ; ZVFHMIN-NEXT: vse32.v v8, (a2)
40 %c = fpext <2 x half> %a to <2 x float>
41 %d = fpext <2 x half> %b to <2 x float>
42 %d2 = fpext <2 x half> %b2 to <2 x float>
43 %e = fmul <2 x float> %c, %d
44 %f = fadd <2 x float> %c, %d2
45 %g = fsub <2 x float> %d, %d2
46 store <2 x float> %e, ptr %x
47 store <2 x float> %f, ptr %y
48 store <2 x float> %g, ptr %z
52 define void @vfwmul_v2f32_multiple_users(ptr %x, ptr %y, ptr %z, <2 x float> %a, <2 x float> %b, <2 x float> %b2) {
53 ; NO_FOLDING-LABEL: vfwmul_v2f32_multiple_users:
54 ; NO_FOLDING: # %bb.0:
55 ; NO_FOLDING-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
56 ; NO_FOLDING-NEXT: vfwcvt.f.f.v v11, v8
57 ; NO_FOLDING-NEXT: vfwcvt.f.f.v v8, v9
58 ; NO_FOLDING-NEXT: vfwcvt.f.f.v v9, v10
59 ; NO_FOLDING-NEXT: vsetvli zero, zero, e64, m1, ta, ma
60 ; NO_FOLDING-NEXT: vfmul.vv v10, v11, v8
61 ; NO_FOLDING-NEXT: vfadd.vv v11, v11, v9
62 ; NO_FOLDING-NEXT: vfsub.vv v8, v8, v9
63 ; NO_FOLDING-NEXT: vse64.v v10, (a0)
64 ; NO_FOLDING-NEXT: vse64.v v11, (a1)
65 ; NO_FOLDING-NEXT: vse64.v v8, (a2)
66 ; NO_FOLDING-NEXT: ret
68 ; FOLDING-LABEL: vfwmul_v2f32_multiple_users:
70 ; FOLDING-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
71 ; FOLDING-NEXT: vfwmul.vv v11, v8, v9
72 ; FOLDING-NEXT: vfwadd.vv v12, v8, v10
73 ; FOLDING-NEXT: vfwsub.vv v8, v9, v10
74 ; FOLDING-NEXT: vse64.v v11, (a0)
75 ; FOLDING-NEXT: vse64.v v12, (a1)
76 ; FOLDING-NEXT: vse64.v v8, (a2)
78 %c = fpext <2 x float> %a to <2 x double>
79 %d = fpext <2 x float> %b to <2 x double>
80 %d2 = fpext <2 x float> %b2 to <2 x double>
81 %e = fmul <2 x double> %c, %d
82 %f = fadd <2 x double> %c, %d2
83 %g = fsub <2 x double> %d, %d2
84 store <2 x double> %e, ptr %x
85 store <2 x double> %f, ptr %y
86 store <2 x double> %g, ptr %z