[llvm] 1dd5e6f - [RISCV] Use vmv.s.x instead of vfmv.s.f when the floating point scalar is 0.
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 29 18:35:30 PST 2021
Author: jacquesguan
Date: 2021-12-30T10:16:54+08:00
New Revision: 1dd5e6fed5dbfe105451277d749e3c4240b925c4
URL: https://github.com/llvm/llvm-project/commit/1dd5e6fed5dbfe105451277d749e3c4240b925c4
DIFF: https://github.com/llvm/llvm-project/commit/1dd5e6fed5dbfe105451277d749e3c4240b925c4.diff
LOG: [RISCV] Use vmv.s.x instead of vfmv.s.f when the floating point scalar is 0.
Use integer vector scalar move instruction when move 0 to avoid add a integer-float move instruction.
Differential Revision: https://reviews.llvm.org/D116365
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
index 73b97e1c36759..0f7db335a0904 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
@@ -1367,6 +1367,11 @@ let Predicates = [HasVInstructionsAnyF] in {
// 17.2. Floating-Point Scalar Move Instructions
foreach vti = AllFloatVectors in {
+ def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
+ (vti.Scalar (fpimm0)),
+ VLOpFrag)),
+ (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
+ vti.RegClass:$merge, X0, GPR:$vl, vti.Log2SEW)>;
def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
vti.ScalarRegClass:$rs1,
VLOpFrag)),
diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll
index 717824031e179..90f3a138b2210 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll
@@ -86,9 +86,8 @@ define void @buildvec_dominant0_v2f32(<2 x float>* %x) {
; CHECK-NEXT: addi a1, a1, %lo(.LCPI2_0)
; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, mu
; CHECK-NEXT: vlse32.v v8, (a1), zero
-; CHECK-NEXT: fmv.w.x ft0, zero
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, tu, mu
-; CHECK-NEXT: vfmv.s.f v8, ft0
+; CHECK-NEXT: vmv.s.x v8, zero
; CHECK-NEXT: vse32.v v8, (a0)
; CHECK-NEXT: ret
store <2 x float> <float 0.0, float 1.0>, <2 x float>* %x
@@ -118,8 +117,7 @@ define void @buildvec_dominant0_v4f32(<4 x float>* %x) {
; CHECK-NEXT: lui a1, %hi(.LCPI4_0)
; CHECK-NEXT: addi a1, a1, %lo(.LCPI4_0)
; CHECK-NEXT: vlse32.v v8, (a1), zero
-; CHECK-NEXT: fmv.w.x ft0, zero
-; CHECK-NEXT: vfmv.s.f v9, ft0
+; CHECK-NEXT: vmv.s.x v9, zero
; CHECK-NEXT: vsetivli zero, 3, e32, m1, tu, mu
; CHECK-NEXT: vslideup.vi v8, v9, 2
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, mu
@@ -132,9 +130,8 @@ define void @buildvec_dominant0_v4f32(<4 x float>* %x) {
define void @buildvec_dominant1_v4f32(<4 x float>* %x, float %f) {
; CHECK-LABEL: buildvec_dominant1_v4f32:
; CHECK: # %bb.0:
-; CHECK-NEXT: fmv.w.x ft0, zero
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, mu
-; CHECK-NEXT: vfmv.s.f v8, ft0
+; CHECK-NEXT: vmv.s.x v8, zero
; CHECK-NEXT: vfmv.v.f v9, fa0
; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, mu
; CHECK-NEXT: vslideup.vi v9, v8, 1
More information about the llvm-commits
mailing list