On Wed, May 14, 2025 at 10:46 PM Jonathan Wakely <jwak...@redhat.com> wrote:

> Use __builtin_signbit directly instead of std::signbit.
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/complex (arg(T)): Use __builtin_signbit instead of
>         std::signbit.
> ---
>
> This would avoid overload resolution for std::signbit, and avoid a
> function call for -O0, but I'm not sure it's worth bothering.
>
You already did it, tested it and pushed a patch, so I see no reason to
not commit it. LGTM

>
> Tested x86_64-linux.
>
>  libstdc++-v3/include/std/complex | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/complex
> b/libstdc++-v3/include/std/complex
> index 67f37d4ec2b7..d9d2d8afda89 100644
> --- a/libstdc++-v3/include/std/complex
> +++ b/libstdc++-v3/include/std/complex
> @@ -2532,8 +2532,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      {
>        typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
>  #if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
> -      return std::signbit(__x) ?
> __type(3.1415926535897932384626433832795029L)
> -                              : __type();
> +      return __builtin_signbit(__type(__x))
> +              ? __type(3.1415926535897932384626433832795029L) : __type();
>  #else
>        return std::arg(std::complex<__type>(__x));
>  #endif
> --
> 2.49.0
>
>

Reply via email to