Skip to content

Commit 8fc4fce

Browse files
jacquesguanjacquesguan
jacquesguan
authored and
jacquesguan
committed
[RISCV] Add VL patterns for vector widening floating-point fused multiply-add instructions.
This patch adds VL patterns for vector widening floating-point fused multiply-add instructions to support fixed length vector type. Differential Revision: https://reviews.llvm.org/D124505
1 parent da201aa commit 8fc4fce

File tree

2 files changed

+1474
-0
lines changed

2 files changed

+1474
-0
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td

+162
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,162 @@ multiclass VPatNarrowShiftSplat_WX_WI<SDNode op, string instruction_name> {
900900
}
901901
}
902902

903+
multiclass VPatWidenFPMulAccVL_VV_VF<string instruction_name> {
904+
foreach vtiToWti = AllWidenableFloatVectors in {
905+
defvar vti = vtiToWti.Vti;
906+
defvar wti = vtiToWti.Wti;
907+
def : Pat<(riscv_fma_vl
908+
(wti.Vector (riscv_fpextend_vl_oneuse
909+
(vti.Vector vti.RegClass:$rs1),
910+
(vti.Mask true_mask), VLOpFrag)),
911+
(wti.Vector (riscv_fpextend_vl_oneuse
912+
(vti.Vector vti.RegClass:$rs2),
913+
(vti.Mask true_mask), VLOpFrag)),
914+
(wti.Vector wti.RegClass:$rd), (vti.Mask true_mask),
915+
VLOpFrag),
916+
(!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX)
917+
wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
918+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
919+
def : Pat<(riscv_fma_vl
920+
(wti.Vector (riscv_fpextend_vl_oneuse
921+
(vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
922+
(vti.Mask true_mask), VLOpFrag)),
923+
(wti.Vector (riscv_fpextend_vl_oneuse
924+
(vti.Vector vti.RegClass:$rs2),
925+
(vti.Mask true_mask), VLOpFrag)),
926+
(wti.Vector wti.RegClass:$rd), (vti.Mask true_mask),
927+
VLOpFrag),
928+
(!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX)
929+
wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
930+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
931+
}
932+
}
933+
934+
multiclass VPatWidenFPNegMulAccVL_VV_VF<string instruction_name> {
935+
foreach vtiToWti = AllWidenableFloatVectors in {
936+
defvar vti = vtiToWti.Vti;
937+
defvar wti = vtiToWti.Wti;
938+
def : Pat<(riscv_fma_vl
939+
(riscv_fneg_vl
940+
(wti.Vector (riscv_fpextend_vl_oneuse
941+
(vti.Vector vti.RegClass:$rs1),
942+
(vti.Mask true_mask), VLOpFrag)),
943+
(wti.Mask true_mask), VLOpFrag),
944+
(riscv_fpextend_vl_oneuse (vti.Vector vti.RegClass:$rs2),
945+
(vti.Mask true_mask), VLOpFrag),
946+
(riscv_fneg_vl wti.RegClass:$rd, (wti.Mask true_mask),
947+
VLOpFrag),
948+
(vti.Mask true_mask), VLOpFrag),
949+
(!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX)
950+
wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
951+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
952+
def : Pat<(riscv_fma_vl
953+
(riscv_fpextend_vl_oneuse
954+
(vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
955+
(vti.Mask true_mask), VLOpFrag),
956+
(riscv_fneg_vl
957+
(wti.Vector (riscv_fpextend_vl_oneuse
958+
(vti.Vector vti.RegClass:$rs2),
959+
(vti.Mask true_mask), VLOpFrag)),
960+
(vti.Mask true_mask), VLOpFrag),
961+
(riscv_fneg_vl wti.RegClass:$rd, (wti.Mask true_mask),
962+
VLOpFrag),
963+
(vti.Mask true_mask), VLOpFrag),
964+
(!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX)
965+
wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
966+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
967+
def : Pat<(riscv_fma_vl
968+
(riscv_fneg_vl
969+
(wti.Vector (riscv_fpextend_vl_oneuse
970+
(vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
971+
(vti.Mask true_mask), VLOpFrag)),
972+
(vti.Mask true_mask), VLOpFrag),
973+
(riscv_fpextend_vl_oneuse (vti.Vector vti.RegClass:$rs2),
974+
(vti.Mask true_mask), VLOpFrag),
975+
(riscv_fneg_vl wti.RegClass:$rd, (wti.Mask true_mask),
976+
VLOpFrag),
977+
(vti.Mask true_mask), VLOpFrag),
978+
(!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX)
979+
wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
980+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
981+
}
982+
}
983+
984+
multiclass VPatWidenFPMulSacVL_VV_VF<string instruction_name> {
985+
foreach vtiToWti = AllWidenableFloatVectors in {
986+
defvar vti = vtiToWti.Vti;
987+
defvar wti = vtiToWti.Wti;
988+
def : Pat<(riscv_fma_vl
989+
(wti.Vector (riscv_fpextend_vl_oneuse
990+
(vti.Vector vti.RegClass:$rs1),
991+
(vti.Mask true_mask), VLOpFrag)),
992+
(riscv_fpextend_vl_oneuse (vti.Vector vti.RegClass:$rs2),
993+
(vti.Mask true_mask), VLOpFrag),
994+
(riscv_fneg_vl wti.RegClass:$rd, (vti.Mask true_mask),
995+
VLOpFrag),
996+
(vti.Mask true_mask), VLOpFrag),
997+
(!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX)
998+
wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
999+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
1000+
def : Pat<(riscv_fma_vl
1001+
(wti.Vector (riscv_fpextend_vl_oneuse
1002+
(vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
1003+
(vti.Mask true_mask), VLOpFrag)),
1004+
(riscv_fpextend_vl_oneuse (vti.Vector vti.RegClass:$rs2),
1005+
(vti.Mask true_mask), VLOpFrag),
1006+
(riscv_fneg_vl wti.RegClass:$rd, (vti.Mask true_mask),
1007+
VLOpFrag),
1008+
(vti.Mask true_mask), VLOpFrag),
1009+
(!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX)
1010+
wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
1011+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
1012+
}
1013+
}
1014+
1015+
multiclass VPatWidenFPNegMulSacVL_VV_VF<string instruction_name> {
1016+
foreach vtiToWti = AllWidenableFloatVectors in {
1017+
defvar vti = vtiToWti.Vti;
1018+
defvar wti = vtiToWti.Wti;
1019+
def : Pat<(riscv_fma_vl
1020+
(riscv_fneg_vl
1021+
(wti.Vector (riscv_fpextend_vl_oneuse
1022+
(vti.Vector vti.RegClass:$rs1),
1023+
(vti.Mask true_mask), VLOpFrag)),
1024+
(vti.Mask true_mask), VLOpFrag),
1025+
(riscv_fpextend_vl_oneuse (vti.Vector vti.RegClass:$rs2),
1026+
(vti.Mask true_mask), VLOpFrag),
1027+
wti.RegClass:$rd, (wti.Mask true_mask), VLOpFrag),
1028+
(!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX)
1029+
wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
1030+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
1031+
def : Pat<(riscv_fma_vl
1032+
(wti.Vector (riscv_fpextend_vl_oneuse
1033+
(vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
1034+
(vti.Mask true_mask), VLOpFrag)),
1035+
(riscv_fneg_vl
1036+
(wti.Vector (riscv_fpextend_vl_oneuse
1037+
(vti.Vector vti.RegClass:$rs2),
1038+
(vti.Mask true_mask), VLOpFrag)),
1039+
(wti.Mask true_mask), VLOpFrag),
1040+
wti.RegClass:$rd, (wti.Mask true_mask), VLOpFrag),
1041+
(!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX)
1042+
wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
1043+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
1044+
def : Pat<(riscv_fma_vl
1045+
(riscv_fneg_vl
1046+
(wti.Vector (riscv_fpextend_vl_oneuse
1047+
(vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
1048+
(vti.Mask true_mask), VLOpFrag)),
1049+
(vti.Mask true_mask), VLOpFrag),
1050+
(riscv_fpextend_vl_oneuse (vti.Vector vti.RegClass:$rs2),
1051+
(vti.Mask true_mask), VLOpFrag),
1052+
wti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag),
1053+
(!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX)
1054+
wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
1055+
GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
1056+
}
1057+
}
1058+
9031059
//===----------------------------------------------------------------------===//
9041060
// Patterns.
9051061
//===----------------------------------------------------------------------===//
@@ -1408,6 +1564,12 @@ foreach vti = AllFloatVectors in {
14081564
(vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
14091565
}
14101566

1567+
// 14.7. Vector Widening Floating-Point Fused Multiply-Add Instructions
1568+
defm : VPatWidenFPMulAccVL_VV_VF<"PseudoVFWMACC">;
1569+
defm : VPatWidenFPNegMulAccVL_VV_VF<"PseudoVFWNMACC">;
1570+
defm : VPatWidenFPMulSacVL_VV_VF<"PseudoVFWMSAC">;
1571+
defm : VPatWidenFPNegMulSacVL_VV_VF<"PseudoVFWNMSAC">;
1572+
14111573
// 14.11. Vector Floating-Point MIN/MAX Instructions
14121574
defm : VPatBinaryFPVL_VV_VF<riscv_fminnum_vl, "PseudoVFMIN">;
14131575
defm : VPatBinaryFPVL_VV_VF<riscv_fmaxnum_vl, "PseudoVFMAX">;

0 commit comments

Comments
 (0)