forked from OSchip/llvm-project
[RISCV] Add isel patterns for vmacc, vnmsac.
The patch selects VSELECT/VP_MERGE_VL which uses fmadd/fnmsub as true operand and the adden of the fmadd/fnmsub as false operand. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D135330
This commit is contained in:
parent
23f989a2e3
commit
2749b942e9
|
@ -284,6 +284,20 @@ def SDTRVVVecReduce : SDTypeProfile<1, 5, [
|
|||
SDTCVecEltisVT<4, i1>, SDTCisSameNumEltsAs<2, 4>, SDTCisVT<5, XLenVT>
|
||||
]>;
|
||||
|
||||
def riscv_add_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
|
||||
node:$E),
|
||||
(riscv_add_vl node:$A, node:$B, node:$C,
|
||||
node:$D, node:$E), [{
|
||||
return N->hasOneUse();
|
||||
}]>;
|
||||
|
||||
def riscv_sub_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
|
||||
node:$E),
|
||||
(riscv_sub_vl node:$A, node:$B, node:$C,
|
||||
node:$D, node:$E), [{
|
||||
return N->hasOneUse();
|
||||
}]>;
|
||||
|
||||
def riscv_mul_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
|
||||
node:$E),
|
||||
(riscv_mul_vl node:$A, node:$B, node:$C,
|
||||
|
@ -1010,6 +1024,66 @@ multiclass VPatMultiplyAddVL_VV_VX<SDNode op, string instruction_name> {
|
|||
}
|
||||
}
|
||||
|
||||
multiclass VPatMultiplyAccVL_VV_VX<PatFrag op, string instruction_name> {
|
||||
foreach vti = AllIntegerVectors in {
|
||||
defvar suffix = vti.LMul.MX;
|
||||
def : Pat<(riscv_vp_merge_vl (vti.Mask true_mask),
|
||||
(vti.Vector (op vti.RegClass:$rd,
|
||||
(riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag),
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag)),
|
||||
vti.RegClass:$rd, VLOpFrag),
|
||||
(!cast<Instruction>(instruction_name#"_VV_"# suffix)
|
||||
vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
|
||||
GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
|
||||
def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
|
||||
(vti.Vector (op vti.RegClass:$rd,
|
||||
(riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag),
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag)),
|
||||
vti.RegClass:$rd, VLOpFrag),
|
||||
(!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
|
||||
vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
|
||||
(vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
|
||||
def : Pat<(riscv_vp_merge_vl (vti.Mask true_mask),
|
||||
(vti.Vector (op vti.RegClass:$rd,
|
||||
(riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag),
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag)),
|
||||
vti.RegClass:$rd, VLOpFrag),
|
||||
(!cast<Instruction>(instruction_name#"_VX_"# suffix)
|
||||
vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
|
||||
GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
|
||||
def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
|
||||
(vti.Vector (op vti.RegClass:$rd,
|
||||
(riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag),
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag)),
|
||||
vti.RegClass:$rd, VLOpFrag),
|
||||
(!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
|
||||
vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
|
||||
(vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
|
||||
def : Pat<(riscv_vselect_vl (vti.Mask V0),
|
||||
(vti.Vector (op vti.RegClass:$rd,
|
||||
(riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag),
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag)),
|
||||
vti.RegClass:$rd, VLOpFrag),
|
||||
(!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
|
||||
vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
|
||||
(vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
|
||||
def : Pat<(riscv_vselect_vl (vti.Mask V0),
|
||||
(vti.Vector (op vti.RegClass:$rd,
|
||||
(riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag),
|
||||
srcvalue, (vti.Mask true_mask), VLOpFrag)),
|
||||
vti.RegClass:$rd, VLOpFrag),
|
||||
(!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
|
||||
vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
|
||||
(vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
|
||||
}
|
||||
}
|
||||
|
||||
multiclass VPatWidenMultiplyAddVL_VV_VX<PatFrag op1, string instruction_name> {
|
||||
foreach vtiTowti = AllWidenableIntVectors in {
|
||||
defvar vti = vtiTowti.Vti;
|
||||
|
@ -1315,6 +1389,8 @@ defm : VPatBinaryWVL_VV_VX<riscv_vwmulsu_vl, "PseudoVWMULSU">;
|
|||
// 12.13 Vector Single-Width Integer Multiply-Add Instructions
|
||||
defm : VPatMultiplyAddVL_VV_VX<riscv_add_vl, "PseudoVMADD">;
|
||||
defm : VPatMultiplyAddVL_VV_VX<riscv_sub_vl, "PseudoVNMSUB">;
|
||||
defm : VPatMultiplyAccVL_VV_VX<riscv_add_vl_oneuse, "PseudoVMACC">;
|
||||
defm : VPatMultiplyAccVL_VV_VX<riscv_sub_vl_oneuse, "PseudoVNMSAC">;
|
||||
|
||||
// 12.14. Vector Widening Integer Multiply-Add Instructions
|
||||
defm : VPatWidenMultiplyAddVL_VV_VX<riscv_vwmul_vl_oneuse, "PseudoVWMACC">;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue