From a8cb1bb3ced1e6c1ddc6e11cc1acb0fcddb03ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=C3=A8=20Giordano?= Date: Tue, 14 Jan 2025 10:53:26 +0000 Subject: [PATCH] Support native `fma` on riscv64 --- src/llvm-cpufeatures.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/llvm-cpufeatures.cpp b/src/llvm-cpufeatures.cpp index a6e963664b0f3..a9fbc378989c5 100644 --- a/src/llvm-cpufeatures.cpp +++ b/src/llvm-cpufeatures.cpp @@ -62,15 +62,18 @@ static bool have_fma(Function &intr, Function &caller, const Triple &TT) JL_NOTS SmallVector Features; FS.split(Features, ','); for (StringRef Feature : Features) - if (TT.isARM()) { - if (Feature == "+vfp4") - return typ == "f32" || typ == "f64"; - else if (Feature == "+vfp4sp") - return typ == "f32"; - } else if (TT.isX86()) { - if (Feature == "+fma" || Feature == "+fma4") - return typ == "f32" || typ == "f64"; - } + if (TT.isARM()) { + if (Feature == "+vfp4") + return typ == "f32" || typ == "f64"; + else if (Feature == "+vfp4sp") + return typ == "f32"; + } else if (TT.isX86()) { + if (Feature == "+fma" || Feature == "+fma4") + return typ == "f32" || typ == "f64"; + } else if (TT.isRISCV64()) { + if (Feature == "+zfh" || Feature == "+f" || Feature == "+d") + return typ == "f16" || typ == "f32" || typ == "f64"; + } return false; }