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 @@ -415,6 +415,11 @@ (!cast(instruction_name#"_V"#vti.Vti.ScalarSuffix#"_"#vti.Vti.LMul.MX) vti.Vti.RegClass:$rs2, vti.Vti.ScalarRegClass:$rs1, vti.Vti.AVL, vti.Vti.Log2SEW)>; + def : Pat<(op (vti.Wti.Vector (fpext_oneuse (vti.Vti.Vector vti.Vti.RegClass:$rs2))), + (vti.Wti.Vector (SplatFPOp (fpext_oneuse vti.Vti.ScalarRegClass:$rs1)))), + (!cast(instruction_name#"_V"#vti.Vti.ScalarSuffix#"_"#vti.Vti.LMul.MX) + vti.Vti.RegClass:$rs2, vti.Vti.ScalarRegClass:$rs1, + vti.Vti.AVL, vti.Vti.Log2SEW)>; } } @@ -430,6 +435,11 @@ (!cast(instruction_name#"_W"#vti.Vti.ScalarSuffix#"_"#vti.Vti.LMul.MX) vti.Wti.RegClass:$rs2, vti.Vti.ScalarRegClass:$rs1, vti.Vti.AVL, vti.Vti.Log2SEW)>; + def : Pat<(op (vti.Wti.Vector vti.Wti.RegClass:$rs2), + (vti.Wti.Vector (SplatFPOp (fpext_oneuse vti.Vti.ScalarRegClass:$rs1)))), + (!cast(instruction_name#"_W"#vti.Vti.ScalarSuffix#"_"#vti.Vti.LMul.MX) + vti.Wti.RegClass:$rs2, vti.Vti.ScalarRegClass:$rs1, + vti.Vti.AVL, vti.Vti.Log2SEW)>; } } diff --git a/llvm/test/CodeGen/RISCV/rvv/vfwadd-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vfwadd-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vfwadd-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vfwadd-sdnode.ll @@ -32,6 +32,21 @@ ret %ve } +define @vfwadd_vf_nxv1f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_vf_nxv1f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfwadd.vf v9, v8, fa0 +; CHECK-NEXT: vmv1r.v v8, v9 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fadd %vc, %splat + ret %ve +} + define @vfwadd_wv_nxv1f64( %va, %vb) { ; CHECK-LABEL: vfwadd_wv_nxv1f64: ; CHECK: # %bb.0: @@ -57,6 +72,19 @@ ret %vd } +define @vfwadd_wf_nxv1f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_wf_nxv1f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfwadd.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fadd %va, %splat + ret %vd +} + define @vfwadd_vv_nxv2f64( %va, %vb) { ; CHECK-LABEL: vfwadd_vv_nxv2f64: ; CHECK: # %bb.0: @@ -85,6 +113,21 @@ ret %ve } +define @vfwadd_vf_nxv2f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_vf_nxv2f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu +; CHECK-NEXT: vfwadd.vf v10, v8, fa0 +; CHECK-NEXT: vmv2r.v v8, v10 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fadd %vc, %splat + ret %ve +} + define @vfwadd_wv_nxv2f64( %va, %vb) { ; CHECK-LABEL: vfwadd_wv_nxv2f64: ; CHECK: # %bb.0: @@ -110,6 +153,19 @@ ret %vd } +define @vfwadd_wf_nxv2f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_wf_nxv2f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu +; CHECK-NEXT: vfwadd.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fadd %va, %splat + ret %vd +} + define @vfwadd_vv_nxv4f64( %va, %vb) { ; CHECK-LABEL: vfwadd_vv_nxv4f64: ; CHECK: # %bb.0: @@ -138,6 +194,21 @@ ret %ve } +define @vfwadd_vf_nxv4f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_vf_nxv4f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu +; CHECK-NEXT: vfwadd.vf v12, v8, fa0 +; CHECK-NEXT: vmv4r.v v8, v12 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fadd %vc, %splat + ret %ve +} + define @vfwadd_wv_nxv4f64( %va, %vb) { ; CHECK-LABEL: vfwadd_wv_nxv4f64: ; CHECK: # %bb.0: @@ -163,6 +234,19 @@ ret %vd } +define @vfwadd_wf_nxv4f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_wf_nxv4f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu +; CHECK-NEXT: vfwadd.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fadd %va, %splat + ret %vd +} + define @vfwadd_vv_nxv8f64( %va, %vb) { ; CHECK-LABEL: vfwadd_vv_nxv8f64: ; CHECK: # %bb.0: @@ -191,6 +275,21 @@ ret %ve } +define @vfwadd_vf_nxv8f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_vf_nxv8f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vfwadd.vf v16, v8, fa0 +; CHECK-NEXT: vmv8r.v v8, v16 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fadd %vc, %splat + ret %ve +} + define @vfwadd_wv_nxv8f64( %va, %vb) { ; CHECK-LABEL: vfwadd_wv_nxv8f64: ; CHECK: # %bb.0: @@ -215,3 +314,16 @@ %vd = fadd %va, %vc ret %vd } + +define @vfwadd_wf_nxv8f64_2( %va, float %b) { +; CHECK-LABEL: vfwadd_wf_nxv8f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vfwadd.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fadd %va, %splat + ret %vd +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vfwmul-sdnode.ll @@ -32,6 +32,21 @@ ret %ve } +define @vfwmul_vf_nxv1f64_2( %va, float %b) { +; CHECK-LABEL: vfwmul_vf_nxv1f64_2: +; 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 + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fmul %vc, %splat + ret %ve +} + define @vfwmul_vv_nxv2f64( %va, %vb) { ; CHECK-LABEL: vfwmul_vv_nxv2f64: ; CHECK: # %bb.0: @@ -60,6 +75,21 @@ ret %ve } +define @vfwmul_vf_nxv2f64_2( %va, float %b) { +; CHECK-LABEL: vfwmul_vf_nxv2f64_2: +; 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 + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fmul %vc, %splat + ret %ve +} + define @vfwmul_vv_nxv4f64( %va, %vb) { ; CHECK-LABEL: vfwmul_vv_nxv4f64: ; CHECK: # %bb.0: @@ -88,6 +118,21 @@ ret %ve } +define @vfwmul_vf_nxv4f64_2( %va, float %b) { +; CHECK-LABEL: vfwmul_vf_nxv4f64_2: +; 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 + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fmul %vc, %splat + ret %ve +} + define @vfwmul_vv_nxv8f64( %va, %vb) { ; CHECK-LABEL: vfwmul_vv_nxv8f64: ; CHECK: # %bb.0: @@ -115,3 +160,18 @@ %ve = fmul %vc, %vd ret %ve } + +define @vfwmul_vf_nxv8f64_2( %va, float %b) { +; CHECK-LABEL: vfwmul_vf_nxv8f64_2: +; 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 + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fmul %vc, %splat + ret %ve +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vfwsub-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vfwsub-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vfwsub-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vfwsub-sdnode.ll @@ -32,6 +32,21 @@ ret %ve } +define @vfwsub_vf_nxv1f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_vf_nxv1f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfwsub.vf v9, v8, fa0 +; CHECK-NEXT: vmv1r.v v8, v9 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fsub %vc, %splat + ret %ve +} + define @vfwsub_wv_nxv1f64( %va, %vb) { ; CHECK-LABEL: vfwsub_wv_nxv1f64: ; CHECK: # %bb.0: @@ -57,6 +72,19 @@ ret %vd } +define @vfwsub_wf_nxv1f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_wf_nxv1f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfwsub.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fsub %va, %splat + ret %vd +} + define @vfwsub_vv_nxv2f64( %va, %vb) { ; CHECK-LABEL: vfwsub_vv_nxv2f64: ; CHECK: # %bb.0: @@ -85,6 +113,21 @@ ret %ve } +define @vfwsub_vf_nxv2f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_vf_nxv2f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu +; CHECK-NEXT: vfwsub.vf v10, v8, fa0 +; CHECK-NEXT: vmv2r.v v8, v10 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fsub %vc, %splat + ret %ve +} + define @vfwsub_wv_nxv2f64( %va, %vb) { ; CHECK-LABEL: vfwsub_wv_nxv2f64: ; CHECK: # %bb.0: @@ -110,6 +153,19 @@ ret %vd } +define @vfwsub_wf_nxv2f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_wf_nxv2f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu +; CHECK-NEXT: vfwsub.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fsub %va, %splat + ret %vd +} + define @vfwsub_vv_nxv4f64( %va, %vb) { ; CHECK-LABEL: vfwsub_vv_nxv4f64: ; CHECK: # %bb.0: @@ -138,6 +194,21 @@ ret %ve } +define @vfwsub_vf_nxv4f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_vf_nxv4f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu +; CHECK-NEXT: vfwsub.vf v12, v8, fa0 +; CHECK-NEXT: vmv4r.v v8, v12 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fsub %vc, %splat + ret %ve +} + define @vfwsub_wv_nxv4f64( %va, %vb) { ; CHECK-LABEL: vfwsub_wv_nxv4f64: ; CHECK: # %bb.0: @@ -163,6 +234,19 @@ ret %vd } +define @vfwsub_wf_nxv4f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_wf_nxv4f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu +; CHECK-NEXT: vfwsub.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fsub %va, %splat + ret %vd +} + define @vfwsub_vv_nxv8f64( %va, %vb) { ; CHECK-LABEL: vfwsub_vv_nxv8f64: ; CHECK: # %bb.0: @@ -191,6 +275,21 @@ ret %ve } +define @vfwsub_vf_nxv8f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_vf_nxv8f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vfwsub.vf v16, v8, fa0 +; CHECK-NEXT: vmv8r.v v8, v16 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vc = fpext %va to + %ve = fsub %vc, %splat + ret %ve +} + define @vfwsub_wv_nxv8f64( %va, %vb) { ; CHECK-LABEL: vfwsub_wv_nxv8f64: ; CHECK: # %bb.0: @@ -215,3 +314,16 @@ %vd = fsub %va, %vc ret %vd } + +define @vfwsub_wf_nxv8f64_2( %va, float %b) { +; CHECK-LABEL: vfwsub_wf_nxv8f64_2: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vfwsub.wf v8, v8, fa0 +; CHECK-NEXT: ret + %fpext = fpext float %b to double + %head = insertelement poison, double %fpext, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vd = fsub %va, %splat + ret %vd +}