Skip to content

Commit 1af8f30

Browse files
4vtomatmikolaj-pirog
authored andcommitted
[llvm][RISCV] Handle fpround and fpextend for zvfbfa without zvfbfmin (llvm#164366)
Add codegen support for fpround and fpextend for zvfbfa. resolve llvm#164324
1 parent d797cb9 commit 1af8f30

File tree

3 files changed

+2557
-628
lines changed

3 files changed

+2557
-628
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZvfbf.td

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,4 +668,38 @@ foreach vti = NoGroupBF16Vectors in {
668668
def : Pat<(vti.Scalar (extractelt (vti.Vector vti.RegClass:$rs2), 0)),
669669
(vfmv_f_s_inst vti.RegClass:$rs2, vti.Log2SEW)>;
670670
}
671+
672+
let Predicates = [HasStdExtZvfbfa] in {
673+
foreach fvtiToFWti = AllWidenableBF16ToFloatVectors in {
674+
defvar fvti = fvtiToFWti.Vti;
675+
defvar fwti = fvtiToFWti.Wti;
676+
def : Pat<(fwti.Vector (any_riscv_fpextend_vl
677+
(fvti.Vector fvti.RegClass:$rs1),
678+
(fvti.Mask VMV0:$vm),
679+
VLOpFrag)),
680+
(!cast<Instruction>("PseudoVFWCVT_F_F_ALT_V_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
681+
(fwti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
682+
(fvti.Mask VMV0:$vm),
683+
GPR:$vl, fvti.Log2SEW, TA_MA)>;
684+
685+
def : Pat<(fvti.Vector (any_riscv_fpround_vl
686+
(fwti.Vector fwti.RegClass:$rs1),
687+
(fwti.Mask VMV0:$vm), VLOpFrag)),
688+
(!cast<Instruction>("PseudoVFNCVT_F_F_ALT_W_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
689+
(fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
690+
(fwti.Mask VMV0:$vm),
691+
// Value to indicate no rounding mode change in
692+
// RISCVInsertReadWriteCSR
693+
FRM_DYN,
694+
GPR:$vl, fvti.Log2SEW, TA_MA)>;
695+
def : Pat<(fvti.Vector (fpround (fwti.Vector fwti.RegClass:$rs1))),
696+
(!cast<Instruction>("PseudoVFNCVT_F_F_ALT_W_"#fvti.LMul.MX#"_E"#fvti.SEW)
697+
(fvti.Vector (IMPLICIT_DEF)),
698+
fwti.RegClass:$rs1,
699+
// Value to indicate no rounding mode change in
700+
// RISCVInsertReadWriteCSR
701+
FRM_DYN,
702+
fvti.AVL, fvti.Log2SEW, TA_MA)>;
703+
}
704+
}
671705
} // Predicates = [HasStdExtZvfbfa]

0 commit comments

Comments
 (0)