mbox series

[0/4] Remove UB and optimize ilogbf/ilogb

Message ID 20250425205309.3866442-1-adhemerval.zanella@linaro.org
Headers show
Series Remove UB and optimize ilogbf/ilogb | expand

Message

Adhemerval Zanella April 25, 2025, 8:44 p.m. UTC
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