[PATCH 7/8] math: Use stdbit.h instead of builtin in math_config.h

Wilco Dijkstra Wilco.Dijkstra@arm.com
Mon Oct 13 16:19:40 GMT 2025


Hi,

> @@ -101,8 +102,8 @@ roundevenf_finite (float x)
>    if (fabs (x - y) == 0.5)
>      {
>        union { float f; uint32_t i; } u = {y};
> -      union { float f; uint32_t i; } v = {y - copysignf (1.0, x)};
> -      if (__builtin_ctzl (v.i) > __builtin_ctzl (u.i))
> +      union { float f; uint32_t i; } v = {y - copysignf (1.0f, x)};
> +      if (stdc_trailing_zeros (v.i) > stdc_trailing_zeros (u.i))
>          y = v.f;
>      }
>    return y;

> Is this potentially a pessimization because stdc_trailing_zeros has a
> defined value at zero?

It shouldn't since the if is extremely rare. In fact I don't see why we need
to use roundeven at all in most cases (since the abs difference is always 0.5,
and we already need to handle the previous/next values correctly anyway).

Cheers,
Wilco


More information about the Libc-alpha mailing list