Skip to content

Commit e0110a4

Browse files
committed
[RISCV] Add intrinsics for vfmv.v.f
Also include a special case pattern to use vmv.v.x vd, zero when the argument is 0.0. Reviewed By: khchen Differential Revision: https://reviews.llvm.org/D93672
1 parent a944887 commit e0110a4

File tree

4 files changed

+876
-1
lines changed

4 files changed

+876
-1
lines changed

llvm/include/llvm/IR/IntrinsicsRISCV.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ let TargetPrefix = "riscv" in {
528528
[IntrNoMem]>, RISCVVIntrinsic {
529529
let ExtendOperand = 1;
530530
}
531+
def int_riscv_vfmv_v_f : Intrinsic<[llvm_anyfloat_ty],
532+
[LLVMVectorElementType<0>, llvm_anyint_ty],
533+
[IntrNoMem]>, RISCVVIntrinsic;
534+
531535
def int_riscv_vmv_x_s : Intrinsic<[LLVMVectorElementType<0>],
532536
[llvm_anyint_ty],
533537
[IntrNoMem]>, RISCVVIntrinsic;

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ multiclass VPseudoUnaryV_V_X_I_NoDummyMask {
779779
}
780780
}
781781

782+
multiclass VPseudoUnaryV_F_NoDummyMask {
783+
foreach m = MxList.m in {
784+
let VLMul = m.value in {
785+
def "_F_" # m.MX : VPseudoUnaryNoDummyMask<m.vrclass, FPR32>;
786+
}
787+
}
788+
}
789+
782790
// The destination EEW is 1.
783791
// The source EEW is 8, 16, 32, or 64.
784792
// When the destination EEW is different from source EEW, we need to use
@@ -1995,12 +2003,16 @@ defm PseudoVMFLE : VPseudoBinaryM_VV_VX</*IsFloat=*/1>;
19952003
defm PseudoVMFGT : VPseudoBinaryM_VX</*IsFloat=*/1>;
19962004
defm PseudoVMFGE : VPseudoBinaryM_VX</*IsFloat=*/1>;
19972005

2006+
//===----------------------------------------------------------------------===//
2007+
// 14.14. Vector Floating-Point Move Instruction
2008+
//===----------------------------------------------------------------------===//
2009+
defm PseudoVFMV_V : VPseudoUnaryV_F_NoDummyMask;
2010+
19982011
//===----------------------------------------------------------------------===//
19992012
// 14.15. Vector Floating-Point Merge Instruction
20002013
//===----------------------------------------------------------------------===//
20012014
defm PseudoVFMERGE : VPseudoBinaryV_XM</*CarryOut =*/0,/*CarryIn =*/true,
20022015
/*Constraint =*/"", /*IsFloat=*/true>;
2003-
20042016
} // Predicates = [HasStdExtV, HasStdExtF]
20052017

20062018
//===----------------------------------------------------------------------===//
@@ -2414,6 +2426,23 @@ defm "" : VPatBinaryM_VV_VX<"int_riscv_vmfne", "PseudoVMFNE", AllFloatVectors>;
24142426
defm "" : VPatBinaryM_VX<"int_riscv_vmfgt", "PseudoVMFGT", AllFloatVectors>;
24152427
defm "" : VPatBinaryM_VX<"int_riscv_vmfge", "PseudoVMFGE", AllFloatVectors>;
24162428

2429+
//===----------------------------------------------------------------------===//
2430+
// 14.14. Vector Floating-Point Move Instruction
2431+
//===----------------------------------------------------------------------===//
2432+
foreach fvti = AllFloatVectors in {
2433+
// If we're splatting fpimm0, use vmv.v.x vd, x0.
2434+
def : Pat<(fvti.Vector (int_riscv_vfmv_v_f
2435+
(fvti.Scalar (fpimm0)), GPR:$vl)),
2436+
(!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX)
2437+
X0, (NoX0 GPR:$vl), fvti.SEW)>;
2438+
2439+
def : Pat<(fvti.Vector (int_riscv_vfmv_v_f
2440+
(fvti.Scalar fvti.ScalarRegClass:$rs2), GPR:$vl)),
2441+
(!cast<Instruction>("PseudoVFMV_V_F_"#fvti.LMul.MX)
2442+
ToFPR32<fvti.Scalar, fvti.ScalarRegClass, "rs2">.ret,
2443+
(NoX0 GPR:$vl), fvti.SEW)>;
2444+
}
2445+
24172446
//===----------------------------------------------------------------------===//
24182447
// 14.15. Vector Floating-Point Merge Instruction
24192448
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)