[llvm] [AMDGPU] expand-fp: Change frem expansion criterion (PR #158285)
Frederik Harwath via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 31 02:45:48 PDT 2025
================
@@ -74,11 +74,54 @@ class FRemExpander {
/// Constant 1 of type \p ExTy.
Value *One;
+ /// The frem argument/return types that can be expanded by this class.
+ // TODO The expansion could work for other floating point types
+ // as well, but this would require additional testing.
+ static constexpr std::array<MVT, 3> ExpandableTypes{MVT::f16, MVT::f32,
+ MVT::f64};
+
+ /// Libcalls for frem instructions of the type at the corresponding
+ /// positions of ExpandableTypes.
+ static constexpr std::array<RTLIB::Libcall, 3> FremLibcalls{
+ RTLIB::REM_F32, RTLIB::REM_F32, RTLIB::REM_F64};
+
+ /// Return the Libcall for frem instructions of expandable type \p VT or
+ /// std::nullopt if \p VT is not expandable.
+ static std::optional<RTLIB::Libcall> getFremLibcallForType(EVT VT) {
+ MVT V = VT.getSimpleVT();
+ for (unsigned I = 0; I < ExpandableTypes.size(); I++)
+ if (ExpandableTypes[I] == V)
+ return FremLibcalls[I];
+
+ return {};
+ };
+
public:
static bool canExpandType(Type *Ty) {
----------------
frederik-h wrote:
`getFremLibcallforType` wasn't used anymore and has been removed now.
https://github.com/llvm/llvm-project/pull/158285
More information about the llvm-commits
mailing list