diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td @@ -694,6 +694,9 @@ defm : VPatBinaryFPSDNode_VV_VF; defm : VPatBinaryFPSDNode_R_VF; +// 14.5. Vector Widening Floating-Point Multiply Instructions +defm : VPatWidenBinaryFPSDNode_VV_VF; + // 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 --- /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 @vfwmul_vv_nxv1f64( %va, %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 %va to + %vd = fpext %vb to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vf_nxv1f64( %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 undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = fpext %va to + %vd = fpext %splat to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vv_nxv2f64( %va, %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 %va to + %vd = fpext %vb to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vf_nxv2f64( %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 undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = fpext %va to + %vd = fpext %splat to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vv_nxv4f64( %va, %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 %va to + %vd = fpext %vb to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vf_nxv4f64( %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 undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = fpext %va to + %vd = fpext %splat to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vv_nxv8f64( %va, %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 %va to + %vd = fpext %vb to + %ve = fmul %vc, %vd + ret %ve +} + +define @vfwmul_vf_nxv8f64( %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 undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = fpext %va to + %vd = fpext %splat to + %ve = fmul %vc, %vd + ret %ve +}