[PATCH 0/4] Remove UB and optimize ilogbf/ilogb
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Apr 25 20:44:06 GMT 2025
>From a recent experiment to build glibc with -fsanitize=undefined [1],
I found that both the float and double ilogb triggered UB due to the
use of shift with a signed integer.
This patchset fixes the UB issues on both implementations by
reimplementing with a slightly better code.
[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/ubsan-undef
Adhemerval Zanella (4):
math: Remove UB and optimize double ilogb
math: Optimize double ilogb/llogb
math: Remove UB and optimize double ilogbf
math: Optimize float ilogb/llogb
sysdeps/ieee754/dbl-64/e_ilogb.c | 64 +---------------------------
sysdeps/ieee754/dbl-64/w_ilogb.c | 69 ++++++++++++++++++++++++++++++
sysdeps/ieee754/dbl-64/w_llogb.c | 2 +
sysdeps/ieee754/flt-32/e_ilogbf.c | 44 +------------------
sysdeps/ieee754/flt-32/w_ilogbf.c | 70 +++++++++++++++++++++++++++++++
sysdeps/ieee754/flt-32/w_llogbf.c | 2 +
6 files changed, 145 insertions(+), 106 deletions(-)
create mode 100644 sysdeps/ieee754/dbl-64/w_ilogb.c
create mode 100644 sysdeps/ieee754/dbl-64/w_llogb.c
create mode 100644 sysdeps/ieee754/flt-32/w_ilogbf.c
create mode 100644 sysdeps/ieee754/flt-32/w_llogbf.c
--
2.43.0
More information about the Libc-alpha
mailing list