[libcxx-commits] [clang] [libcxx] [Clang] Allow __builtin_fma/fmaf/fmal to be used in a constant expression (PR #158048)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 17 02:53:26 PDT 2025
================
@@ -194,11 +194,19 @@ int main(int, char**) {
ASSERT_NOT_CONSTEXPR_CXX23(std::fminf(1.0f, 0.0f) == 0.0f);
ASSERT_NOT_CONSTEXPR_CXX23(std::fminl(1.0L, 0.0L) == 0.0L);
+#if !__has_constexpr_builtin(__builtin_fma)
ASSERT_NOT_CONSTEXPR_CXX23(std::fma(1.0f, 1.0f, 1.0f) == 2.0f);
ASSERT_NOT_CONSTEXPR_CXX23(std::fma(1.0, 1.0, 1.0) == 2.0);
ASSERT_NOT_CONSTEXPR_CXX23(std::fma(1.0L, 1.0L, 1.0L) == 2.0L);
ASSERT_NOT_CONSTEXPR_CXX23(std::fmaf(1.0f, 1.0f, 1.0f) == 2.0f);
ASSERT_NOT_CONSTEXPR_CXX23(std::fmal(1.0L, 1.0L, 1.0L) == 2.0L);
+#else
+ ASSERT_CONSTEXPR_CXX23(std::fma(1.0f, 1.0f, 1.0f) == 2.0f);
+ ASSERT_CONSTEXPR_CXX23(std::fma(1.0, 1.0, 1.0) == 2.0);
+ ASSERT_CONSTEXPR_CXX23(std::fma(1.0L, 1.0L, 1.0L) == 2.0L);
----------------
philnik777 wrote:
The `float` and `long double` overloads aren't constexpr yet, since libc++ provides them, so they should still be `ASSERT_NOT_CONSTEXPR_CXX23`. That should make the CI happy (except possibly macOS - they're currently red due to an OS update)
https://github.com/llvm/llvm-project/pull/158048
More information about the libcxx-commits
mailing list