[PATCH] D134369: [Clang] Support constexpr builtin fmax

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 29 09:53:39 PDT 2022


efriedma added inline comments.


================
Comment at: clang/test/Sema/constant-builtins-fmax.cpp:35-39
+#define FMAX_TEST_BOTH_ZERO(T, FUNC)       \
+    static_assert(0.0 == FUNC(0.0, 0.0));  \
+    static_assert(0.0 == FUNC(-0.0, 0.0)); \
+    static_assert(0.0 == FUNC(0.0, -0.0)); \
+    static_assert(0.0 == FUNC(-0.0, -0.0));
----------------
Izaron wrote:
> jcranmer-intel wrote:
> > These tests aren't covering what the sign of zero is in these cases.
> Cool! Thank you, today I learned that this compiles:
> ```
> static_assert(0.0 == 0.0);
> static_assert(0.0 == -0.0);
> static_assert(0.0 == +0.0);
> ```
> 
> So I think I need to test the `+0.0` cases with the `__builtin_signbit` (I didn't find another way), BUT this function is not constexpr yet. So I need to implement a constexpr `__builtin_signbit` first... In a new pull request.
I think __builtin_copysign should be sufficient.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134369/new/

https://reviews.llvm.org/D134369



More information about the cfe-commits mailing list