[llvm] 1090000 - [RISCV] Add patterns for vector widening floating-point multiply
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 17 23:00:12 PST 2022
Author: jacquesguan
Date: 2022-01-18T14:52:43+08:00
New Revision: 1090000b63f939052486080a143175775c1edbdc
URL: https://github.com/llvm/llvm-project/commit/1090000b63f939052486080a143175775c1edbdc
DIFF: https://github.com/llvm/llvm-project/commit/1090000b63f939052486080a143175775c1edbdc.diff
LOG: [RISCV] Add patterns for vector widening floating-point multiply
Add patterns for vector widening floating-point multiply
Differential Revision: https://reviews.llvm.org/D117530
Added:
llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
index 70aa0febd36f8..078025051e716 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
@@ -694,6 +694,9 @@ defm : VPatBinaryFPSDNode_VV_VF<fmul, "PseudoVFMUL">;
defm : VPatBinaryFPSDNode_VV_VF<fdiv, "PseudoVFDIV">;
defm : VPatBinaryFPSDNode_R_VF<fdiv, "PseudoVFRDIV">;
+// 14.5. Vector Widening Floating-Point Multiply Instructions
+defm : VPatWidenBinaryFPSDNode_VV_VF<fmul, "PseudoVFWMUL">;
+
// 14.6 Vector Single-Width Floating-Point Fused Multiply-Add Instructions.
foreach fvti = AllFloatVectors in {
// NOTE: We choose VFMADD because it has the most commuting freedom. So it
diff --git a/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll
new file mode 100644
index 0000000000000..ba29aacf595f3
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll
@@ -0,0 +1,117 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+experimental-v -target-abi=ilp32d \
+; RUN: -verify-machineinstrs < %s | FileCheck %s
+; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+experimental-v -target-abi=lp64d \
+; RUN: -verify-machineinstrs < %s | FileCheck %s
+
+define <vscale x 1 x double> @vfwmul_vv_nxv1f64(<vscale x 1 x float> %va, <vscale x 1 x float> %vb) {
+; CHECK-LABEL: vfwmul_vv_nxv1f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu
+; CHECK-NEXT: vfwmul.vv v10, v8, v9
+; CHECK-NEXT: vmv1r.v v8, v10
+; CHECK-NEXT: ret
+ %vc = fpext <vscale x 1 x float> %va to <vscale x 1 x double>
+ %vd = fpext <vscale x 1 x float> %vb to <vscale x 1 x double>
+ %ve = fmul <vscale x 1 x double> %vc, %vd
+ ret <vscale x 1 x double> %ve
+}
+
+define <vscale x 1 x double> @vfwmul_vf_nxv1f64(<vscale x 1 x float> %va, float %b) {
+; CHECK-LABEL: vfwmul_vf_nxv1f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu
+; CHECK-NEXT: vfwmul.vf v9, v8, fa0
+; CHECK-NEXT: vmv1r.v v8, v9
+; CHECK-NEXT: ret
+ %head = insertelement <vscale x 1 x float> undef, float %b, i32 0
+ %splat = shufflevector <vscale x 1 x float> %head, <vscale x 1 x float> undef, <vscale x 1 x i32> zeroinitializer
+ %vc = fpext <vscale x 1 x float> %va to <vscale x 1 x double>
+ %vd = fpext <vscale x 1 x float> %splat to <vscale x 1 x double>
+ %ve = fmul <vscale x 1 x double> %vc, %vd
+ ret <vscale x 1 x double> %ve
+}
+
+define <vscale x 2 x double> @vfwmul_vv_nxv2f64(<vscale x 2 x float> %va, <vscale x 2 x float> %vb) {
+; CHECK-LABEL: vfwmul_vv_nxv2f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu
+; CHECK-NEXT: vfwmul.vv v10, v8, v9
+; CHECK-NEXT: vmv2r.v v8, v10
+; CHECK-NEXT: ret
+ %vc = fpext <vscale x 2 x float> %va to <vscale x 2 x double>
+ %vd = fpext <vscale x 2 x float> %vb to <vscale x 2 x double>
+ %ve = fmul <vscale x 2 x double> %vc, %vd
+ ret <vscale x 2 x double> %ve
+}
+
+define <vscale x 2 x double> @vfwmul_vf_nxv2f64(<vscale x 2 x float> %va, float %b) {
+; CHECK-LABEL: vfwmul_vf_nxv2f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu
+; CHECK-NEXT: vfwmul.vf v10, v8, fa0
+; CHECK-NEXT: vmv2r.v v8, v10
+; CHECK-NEXT: ret
+ %head = insertelement <vscale x 2 x float> undef, float %b, i32 0
+ %splat = shufflevector <vscale x 2 x float> %head, <vscale x 2 x float> undef, <vscale x 2 x i32> zeroinitializer
+ %vc = fpext <vscale x 2 x float> %va to <vscale x 2 x double>
+ %vd = fpext <vscale x 2 x float> %splat to <vscale x 2 x double>
+ %ve = fmul <vscale x 2 x double> %vc, %vd
+ ret <vscale x 2 x double> %ve
+}
+
+define <vscale x 4 x double> @vfwmul_vv_nxv4f64(<vscale x 4 x float> %va, <vscale x 4 x float> %vb) {
+; CHECK-LABEL: vfwmul_vv_nxv4f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu
+; CHECK-NEXT: vfwmul.vv v12, v8, v10
+; CHECK-NEXT: vmv4r.v v8, v12
+; CHECK-NEXT: ret
+ %vc = fpext <vscale x 4 x float> %va to <vscale x 4 x double>
+ %vd = fpext <vscale x 4 x float> %vb to <vscale x 4 x double>
+ %ve = fmul <vscale x 4 x double> %vc, %vd
+ ret <vscale x 4 x double> %ve
+}
+
+define <vscale x 4 x double> @vfwmul_vf_nxv4f64(<vscale x 4 x float> %va, float %b) {
+; CHECK-LABEL: vfwmul_vf_nxv4f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu
+; CHECK-NEXT: vfwmul.vf v12, v8, fa0
+; CHECK-NEXT: vmv4r.v v8, v12
+; CHECK-NEXT: ret
+ %head = insertelement <vscale x 4 x float> undef, float %b, i32 0
+ %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> undef, <vscale x 4 x i32> zeroinitializer
+ %vc = fpext <vscale x 4 x float> %va to <vscale x 4 x double>
+ %vd = fpext <vscale x 4 x float> %splat to <vscale x 4 x double>
+ %ve = fmul <vscale x 4 x double> %vc, %vd
+ ret <vscale x 4 x double> %ve
+}
+
+define <vscale x 8 x double> @vfwmul_vv_nxv8f64(<vscale x 8 x float> %va, <vscale x 8 x float> %vb) {
+; CHECK-LABEL: vfwmul_vv_nxv8f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu
+; CHECK-NEXT: vfwmul.vv v16, v8, v12
+; CHECK-NEXT: vmv8r.v v8, v16
+; CHECK-NEXT: ret
+ %vc = fpext <vscale x 8 x float> %va to <vscale x 8 x double>
+ %vd = fpext <vscale x 8 x float> %vb to <vscale x 8 x double>
+ %ve = fmul <vscale x 8 x double> %vc, %vd
+ ret <vscale x 8 x double> %ve
+}
+
+define <vscale x 8 x double> @vfwmul_vf_nxv8f64(<vscale x 8 x float> %va, float %b) {
+; CHECK-LABEL: vfwmul_vf_nxv8f64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu
+; CHECK-NEXT: vfwmul.vf v16, v8, fa0
+; CHECK-NEXT: vmv8r.v v8, v16
+; CHECK-NEXT: ret
+ %head = insertelement <vscale x 8 x float> undef, float %b, i32 0
+ %splat = shufflevector <vscale x 8 x float> %head, <vscale x 8 x float> undef, <vscale x 8 x i32> zeroinitializer
+ %vc = fpext <vscale x 8 x float> %va to <vscale x 8 x double>
+ %vd = fpext <vscale x 8 x float> %splat to <vscale x 8 x double>
+ %ve = fmul <vscale x 8 x double> %vc, %vd
+ ret <vscale x 8 x double> %ve
+}
More information about the llvm-commits
mailing list