[libc-commits] [libc] [libc][math][c23] Add f16fmaf C23 math function (PR #95483)
via libc-commits
libc-commits at lists.llvm.org
Fri Jun 14 04:13:34 PDT 2024
================
@@ -10,20 +10,28 @@
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_GENERIC_FMA_H
#include "src/__support/CPP/bit.h"
+#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/big_int.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/__support/uint128.h"
+
+#include "hdr/fenv_macros.h"
namespace LIBC_NAMESPACE {
namespace fputil {
namespace generic {
-template <typename T> LIBC_INLINE T fma(T x, T y, T z);
+template <typename OutType, typename InType>
+LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<OutType> &&
+ cpp::is_floating_point_v<InType> &&
+ sizeof(OutType) <= sizeof(InType),
+ OutType>
+fma(InType x, InType y, InType z);
+#ifndef LIBC_TARGET_CPU_HAS_FMA
// TODO(lntue): Implement fmaf that is correctly rounded to all rounding modes.
// The implementation below only is only correct for the default rounding mode,
// round-to-nearest tie-to-even.
----------------
overmighty wrote:
It passes the `fmaf` MPFR unit test (`libc.test.src.math.fmaf_test.__unit__`).
Also, I just realized that the `#ifndef LIBC_TARGET_CPU_HAS_FMA` guard is useless, as this is `fputil::generic::fma`, not `fputil::fma`.
https://github.com/llvm/llvm-project/pull/95483
More information about the libc-commits
mailing list