[PATCH v3 1/6] math: Remove UB and optimize double ilogb
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Fri May 30 13:44:16 GMT 2025
Hi Adhemerval,
> The subnormal exponent calculation invokes UB by left shifting the
> signed expoenent to find the first leading bit. The implementation
Typo: exponent
> also uses 32 bits operations, which generates suboptimal code in
> 64 bits architectures.
>
> The patch reimplements ilogb using the math_config.h macros and
> uses the new stdbit function to simplify the subnormal handling.
LGTM. As a side note, at some point we need to cleanup the various uses
of clz/ctz across GLIBC, there are old uses of count_leading_zeros from
longlong.h (which should really go) as well as many __builtin_clz/ctz.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cheers,
Wilco
More information about the Libc-alpha
mailing list