forked from OSchip/llvm-project
[RISCV] Add support for fixed vector fabs
This commit is contained in:
parent
36658376d5
commit
4220a81c84
|
@ -577,6 +577,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
|
|||
setOperationAction(ISD::FMUL, VT, Custom);
|
||||
setOperationAction(ISD::FDIV, VT, Custom);
|
||||
setOperationAction(ISD::FNEG, VT, Custom);
|
||||
setOperationAction(ISD::FABS, VT, Custom);
|
||||
setOperationAction(ISD::FSQRT, VT, Custom);
|
||||
setOperationAction(ISD::FMA, VT, Custom);
|
||||
}
|
||||
|
@ -1210,6 +1211,8 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
|
|||
return lowerToScalableOp(Op, DAG, RISCVISD::FDIV_VL);
|
||||
case ISD::FNEG:
|
||||
return lowerToScalableOp(Op, DAG, RISCVISD::FNEG_VL);
|
||||
case ISD::FABS:
|
||||
return lowerToScalableOp(Op, DAG, RISCVISD::FABS_VL);
|
||||
case ISD::FSQRT:
|
||||
return lowerToScalableOp(Op, DAG, RISCVISD::FSQRT_VL);
|
||||
case ISD::FMA:
|
||||
|
@ -4742,6 +4745,7 @@ const char *RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {
|
|||
NODE_NAME_CASE(FMUL_VL)
|
||||
NODE_NAME_CASE(FDIV_VL)
|
||||
NODE_NAME_CASE(FNEG_VL)
|
||||
NODE_NAME_CASE(FABS_VL)
|
||||
NODE_NAME_CASE(FSQRT_VL)
|
||||
NODE_NAME_CASE(FMA_VL)
|
||||
NODE_NAME_CASE(SMIN_VL)
|
||||
|
|
|
@ -162,6 +162,7 @@ enum NodeType : unsigned {
|
|||
FMUL_VL,
|
||||
FDIV_VL,
|
||||
FNEG_VL,
|
||||
FABS_VL,
|
||||
FSQRT_VL,
|
||||
FMA_VL,
|
||||
SMIN_VL,
|
||||
|
|
|
@ -73,6 +73,7 @@ def riscv_fsub_vl : SDNode<"RISCVISD::FSUB_VL", SDT_RISCVFPBinOp_VL>;
|
|||
def riscv_fmul_vl : SDNode<"RISCVISD::FMUL_VL", SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
|
||||
def riscv_fdiv_vl : SDNode<"RISCVISD::FDIV_VL", SDT_RISCVFPBinOp_VL>;
|
||||
def riscv_fneg_vl : SDNode<"RISCVISD::FNEG_VL", SDT_RISCVFPUnOp_VL>;
|
||||
def riscv_fabs_vl : SDNode<"RISCVISD::FABS_VL", SDT_RISCVFPUnOp_VL>;
|
||||
def riscv_fsqrt_vl : SDNode<"RISCVISD::FSQRT_VL", SDT_RISCVFPUnOp_VL>;
|
||||
|
||||
def SDT_RISCVVecFMA_VL : SDTypeProfile<1, 5, [SDTCisSameAs<0, 1>,
|
||||
|
@ -449,6 +450,10 @@ foreach vti = AllFloatVectors in {
|
|||
vti.RegClass:$rs2, GPR:$vl, vti.SEW)>;
|
||||
|
||||
// 14.12. Vector Floating-Point Sign-Injection Instructions
|
||||
def : Pat<(riscv_fabs_vl (vti.Vector vti.RegClass:$rs), (vti.Mask true_mask),
|
||||
(XLenVT (VLOp GPR:$vl))),
|
||||
(!cast<Instruction>("PseudoVFSGNJX_VV_"# vti.LMul.MX)
|
||||
vti.RegClass:$rs, vti.RegClass:$rs, GPR:$vl, vti.SEW)>;
|
||||
// Handle fneg with VFSGNJN using the same input for both operands.
|
||||
def : Pat<(riscv_fneg_vl (vti.Vector vti.RegClass:$rs), (vti.Mask true_mask),
|
||||
(XLenVT (VLOp GPR:$vl))),
|
||||
|
|
|
@ -253,6 +253,54 @@ define void @fneg_v2f64(<2 x double>* %x) {
|
|||
ret void
|
||||
}
|
||||
|
||||
define void @fabs_v8f16(<8 x half>* %x) {
|
||||
; CHECK-LABEL: fabs_v8f16:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: addi a1, zero, 8
|
||||
; CHECK-NEXT: vsetvli a1, a1, e16,m1,ta,mu
|
||||
; CHECK-NEXT: vle16.v v25, (a0)
|
||||
; CHECK-NEXT: vfsgnjx.vv v25, v25, v25
|
||||
; CHECK-NEXT: vse16.v v25, (a0)
|
||||
; CHECK-NEXT: ret
|
||||
%a = load <8 x half>, <8 x half>* %x
|
||||
%b = call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
|
||||
store <8 x half> %b, <8 x half>* %x
|
||||
ret void
|
||||
}
|
||||
declare <8 x half> @llvm.fabs.v8f16(<8 x half>)
|
||||
|
||||
define void @fabs_v4f32(<4 x float>* %x) {
|
||||
; CHECK-LABEL: fabs_v4f32:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: addi a1, zero, 4
|
||||
; CHECK-NEXT: vsetvli a1, a1, e32,m1,ta,mu
|
||||
; CHECK-NEXT: vle32.v v25, (a0)
|
||||
; CHECK-NEXT: vfsgnjx.vv v25, v25, v25
|
||||
; CHECK-NEXT: vse32.v v25, (a0)
|
||||
; CHECK-NEXT: ret
|
||||
%a = load <4 x float>, <4 x float>* %x
|
||||
%b = call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
|
||||
store <4 x float> %b, <4 x float>* %x
|
||||
ret void
|
||||
}
|
||||
declare <4 x float> @llvm.fabs.v4f32(<4 x float>)
|
||||
|
||||
define void @fabs_v2f64(<2 x double>* %x) {
|
||||
; CHECK-LABEL: fabs_v2f64:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: addi a1, zero, 2
|
||||
; CHECK-NEXT: vsetvli a1, a1, e64,m1,ta,mu
|
||||
; CHECK-NEXT: vle64.v v25, (a0)
|
||||
; CHECK-NEXT: vfsgnjx.vv v25, v25, v25
|
||||
; CHECK-NEXT: vse64.v v25, (a0)
|
||||
; CHECK-NEXT: ret
|
||||
%a = load <2 x double>, <2 x double>* %x
|
||||
%b = call <2 x double> @llvm.fabs.v2f64(<2 x double> %a)
|
||||
store <2 x double> %b, <2 x double>* %x
|
||||
ret void
|
||||
}
|
||||
declare <2 x double> @llvm.fabs.v2f64(<2 x double>)
|
||||
|
||||
define void @sqrt_v8f16(<8 x half>* %x) {
|
||||
; CHECK-LABEL: sqrt_v8f16:
|
||||
; CHECK: # %bb.0:
|
||||
|
|
Loading…
Reference in New Issue