Skip to content

Commit f4e906a

Browse files
authored
[RISCV] Move more stuff to RISCVInstrInfoZvfbf.td. Fix incorrect Predicates. (#163846)
The PseudoVFWCVTBF16_F_F and PseudoVFNCVTBF16_F_F pseudos should only have Zvfbfmin as their Predicate, they are not used by Zvfofp8min which requires different Pseudos with different SEW. The patterns had an outer Predicates saying ZvfbfminOrZvfofp8min and inner Predicate saying HasVInstructionsMinimal||HasVInstructionsF32. I believe the outer Predicates overrides the inner Predicates. The correct predicate for the patterns is Zvfbfmin(which implies HasVInstructionsF32). They aren't used by Zvfofp8min and HasVInstructionsMinimal is going to be changed to Zvbfmin||Zvfbfa, but these instructions are Zvfbfmin only.
1 parent b3a1994 commit f4e906a

File tree

3 files changed

+39
-43
lines changed

3 files changed

+39
-43
lines changed

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ def HasStdExtZvfbfa : Predicate<"Subtarget->hasStdExtZvfbfa()">,
695695

696696
def FeatureStdExtZvfbfmin
697697
: RISCVExtension<1, 0, "Vector BF16 Converts", [FeatureStdExtZve32f]>;
698+
def HasStdExtZvfbfmin : Predicate<"Subtarget->hasStdExtZvfbfmin()">,
699+
AssemblerPredicate<(all_of FeatureStdExtZvfbfmin),
700+
"'Zvfbfmin' (Vector BF16 Converts)">;
698701

699702
def FeatureStdExtZvfbfwma
700703
: RISCVExtension<1, 0, "Vector BF16 widening mul-add",

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5862,20 +5862,6 @@ multiclass VPatConversionWF_VF<string intrinsic, string instruction,
58625862
}
58635863
}
58645864

5865-
multiclass VPatConversionWF_VF_BF<string intrinsic, string instruction,
5866-
bit isSEWAware = 0> {
5867-
foreach fvtiToFWti = AllWidenableBF16ToFloatVectors in
5868-
{
5869-
defvar fvti = fvtiToFWti.Vti;
5870-
defvar fwti = fvtiToFWti.Wti;
5871-
let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
5872-
GetVTypePredicates<fwti>.Predicates) in
5873-
defm : VPatConversion<intrinsic, instruction, "V",
5874-
fwti.Vector, fvti.Vector, fwti.Mask, fvti.Log2SEW,
5875-
fvti.LMul, fwti.RegClass, fvti.RegClass, isSEWAware>;
5876-
}
5877-
}
5878-
58795865
multiclass VPatConversionVI_WF<string intrinsic, string instruction> {
58805866
foreach vtiToWti = AllWidenableIntToFloatVectors in {
58815867
defvar vti = vtiToWti.Vti;
@@ -5969,20 +5955,6 @@ multiclass VPatConversionVF_WF_RTZ<string intrinsic, string instruction,
59695955
}
59705956
}
59715957

5972-
multiclass VPatConversionVF_WF_BF_RM<string intrinsic, string instruction,
5973-
bit isSEWAware = 0> {
5974-
foreach fvtiToFWti = AllWidenableBF16ToFloatVectors in {
5975-
defvar fvti = fvtiToFWti.Vti;
5976-
defvar fwti = fvtiToFWti.Wti;
5977-
let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
5978-
GetVTypePredicates<fwti>.Predicates) in
5979-
defm : VPatConversionRoundingMode<intrinsic, instruction, "W",
5980-
fvti.Vector, fwti.Vector, fvti.Mask, fvti.Log2SEW,
5981-
fvti.LMul, fvti.RegClass, fwti.RegClass,
5982-
isSEWAware>;
5983-
}
5984-
}
5985-
59865958
multiclass VPatCompare_VI<string intrinsic, string inst,
59875959
ImmLeaf ImmType> {
59885960
foreach vti = AllIntegerVectors in {

llvm/lib/Target/RISCV/RISCVInstrInfoZvfbf.td

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defm VFWMACCBF16_V : VWMAC_FV_V_F<"vfwmaccbf16", 0b111011>;
3636
//===----------------------------------------------------------------------===//
3737
// Pseudo instructions
3838
//===----------------------------------------------------------------------===//
39-
let Predicates = [HasStdExtZvfbfminOrZvfofp8min] in {
39+
let Predicates = [HasStdExtZvfbfmin] in {
4040
defm PseudoVFWCVTBF16_F_F : VPseudoVWCVTD_V;
4141
defm PseudoVFNCVTBF16_F_F : VPseudoVNCVTD_W_RM;
4242
}
@@ -47,7 +47,31 @@ let mayRaiseFPException = true, Predicates = [HasStdExtZvfbfwma] in
4747
//===----------------------------------------------------------------------===//
4848
// Patterns
4949
//===----------------------------------------------------------------------===//
50-
let Predicates = [HasStdExtZvfbfminOrZvfofp8min] in {
50+
multiclass VPatConversionWF_VF_BF<string intrinsic, string instruction,
51+
bit isSEWAware = 0> {
52+
foreach fvtiToFWti = AllWidenableBF16ToFloatVectors in
53+
{
54+
defvar fvti = fvtiToFWti.Vti;
55+
defvar fwti = fvtiToFWti.Wti;
56+
defm : VPatConversion<intrinsic, instruction, "V",
57+
fwti.Vector, fvti.Vector, fwti.Mask, fvti.Log2SEW,
58+
fvti.LMul, fwti.RegClass, fvti.RegClass, isSEWAware>;
59+
}
60+
}
61+
62+
multiclass VPatConversionVF_WF_BF_RM<string intrinsic, string instruction,
63+
bit isSEWAware = 0> {
64+
foreach fvtiToFWti = AllWidenableBF16ToFloatVectors in {
65+
defvar fvti = fvtiToFWti.Vti;
66+
defvar fwti = fvtiToFWti.Wti;
67+
defm : VPatConversionRoundingMode<intrinsic, instruction, "W",
68+
fvti.Vector, fwti.Vector, fvti.Mask, fvti.Log2SEW,
69+
fvti.LMul, fvti.RegClass, fwti.RegClass,
70+
isSEWAware>;
71+
}
72+
}
73+
74+
let Predicates = [HasStdExtZvfbfmin] in {
5175
defm : VPatConversionWF_VF_BF<"int_riscv_vfwcvtbf16_f_f_v",
5276
"PseudoVFWCVTBF16_F_F", isSEWAware=1>;
5377
defm : VPatConversionVF_WF_BF_RM<"int_riscv_vfncvtbf16_f_f_w",
@@ -56,7 +80,6 @@ let Predicates = [HasStdExtZvfbfminOrZvfofp8min] in {
5680
foreach fvtiToFWti = AllWidenableBF16ToFloatVectors in {
5781
defvar fvti = fvtiToFWti.Vti;
5882
defvar fwti = fvtiToFWti.Wti;
59-
let Predicates = [HasVInstructionsBF16Minimal] in
6083
def : Pat<(fwti.Vector (any_riscv_fpextend_vl
6184
(fvti.Vector fvti.RegClass:$rs1),
6285
(fvti.Mask VMV0:$vm),
@@ -66,18 +89,16 @@ let Predicates = [HasStdExtZvfbfminOrZvfofp8min] in {
6689
(fvti.Mask VMV0:$vm),
6790
GPR:$vl, fvti.Log2SEW, TA_MA)>;
6891

69-
let Predicates = [HasVInstructionsBF16Minimal] in
70-
def : Pat<(fvti.Vector (any_riscv_fpround_vl
71-
(fwti.Vector fwti.RegClass:$rs1),
72-
(fwti.Mask VMV0:$vm), VLOpFrag)),
73-
(!cast<Instruction>("PseudoVFNCVTBF16_F_F_W_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
74-
(fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
75-
(fwti.Mask VMV0:$vm),
76-
// Value to indicate no rounding mode change in
77-
// RISCVInsertReadWriteCSR
78-
FRM_DYN,
79-
GPR:$vl, fvti.Log2SEW, TA_MA)>;
80-
let Predicates = [HasVInstructionsBF16Minimal] in
92+
def : Pat<(fvti.Vector (any_riscv_fpround_vl
93+
(fwti.Vector fwti.RegClass:$rs1),
94+
(fwti.Mask VMV0:$vm), VLOpFrag)),
95+
(!cast<Instruction>("PseudoVFNCVTBF16_F_F_W_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
96+
(fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
97+
(fwti.Mask VMV0:$vm),
98+
// Value to indicate no rounding mode change in
99+
// RISCVInsertReadWriteCSR
100+
FRM_DYN,
101+
GPR:$vl, fvti.Log2SEW, TA_MA)>;
81102
def : Pat<(fvti.Vector (fpround (fwti.Vector fwti.RegClass:$rs1))),
82103
(!cast<Instruction>("PseudoVFNCVTBF16_F_F_W_"#fvti.LMul.MX#"_E"#fvti.SEW)
83104
(fvti.Vector (IMPLICIT_DEF)),

0 commit comments

Comments
 (0)