Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++][math] Add constexpr for std::signbit() #105946

Merged
merged 10 commits into from
Sep 5, 2024

Conversation

robincaloudis
Copy link
Contributor

@robincaloudis robincaloudis commented Aug 24, 2024

Why

Since 18th of August, the floating point comparison builtin __builtin_signbit is available in Clang as constant expression (#94118).

What

  • Implement constexpr for std::signbit() as defined by P0533R9 (new C++23 feature)
  • Restrict execution of tests to tip-of-trunk Clang as builtin is not yet available (note that builtin is available in GCC)

Copy link

github-actions bot commented Aug 24, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@robincaloudis robincaloudis force-pushed the rc-signbit branch 25 times, most recently from a22802a to 5ceea95 Compare August 27, 2024 13:47
@robincaloudis robincaloudis marked this pull request as ready for review August 28, 2024 07:27
@robincaloudis robincaloudis requested a review from a team as a code owner August 28, 2024 07:27
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 28, 2024
@robincaloudis
Copy link
Contributor Author

@philnik777, could you have another look?

libcxx/include/__math/traits.h Outdated Show resolved Hide resolved
libcxx/include/__math/traits.h Outdated Show resolved Hide resolved
libcxx/test/std/numerics/c.math/signbit.pass.cpp Outdated Show resolved Hide resolved
We will add the overloads in a seperate
patch.
Custom notes are encoded via GitHub
issues from now on.
@philnik777 philnik777 merged commit 1a12647 into llvm:main Sep 5, 2024
64 checks passed
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Sep 12, 2024
## Why
Since 18th of August, the floating point comparison builtin
``__builtin_signbit`` is available in Clang as constant expression
(llvm#94118).

## What
* Implement `constexpr` for `std::signbit()` as defined by
[P0533R9](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf)
(new C++23 feature)
* Restrict execution of tests to tip-of-trunk Clang as builtin is not
yet available (note that builtin is available in GCC)
philnik777 pushed a commit that referenced this pull request Sep 12, 2024
…pes for `std::signbit` (#106566)

## Why
Following up on #105946, this
patch provides the floating point overloads for `std::signbit` as
defined by
[P0533R9](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf).

## What
* Test and add overloads for cv-unqualified floating point types
* Remove constrained overload as it is not needed anymore
* Make use of `template<class = void>` as the universal C runtime (UCRT)
needed for Clang-Cl comes with overloads for all cv-unqualified floating
point types (float, double, long double) for `std::signbit()` by itself
[in the
WinSDK](https://github.com/microsoft/win32metadata/blob/e012b29924c53aa941fc010850b68331b0c3ea80/generation/WinSDK/RecompiledIdlHeaders/ucrt/corecrt_math.h#L309-L322).
In a certain way, this can be seen as a deviation from the C standard.
We need to work around it as the compilation would otherwise error out
due to duplicated definitions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants