[PATCH v2 00/12] Add binary64 CORE-MATH implementations to libm

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Oct 10 18:15:21 GMT 2025


This patchset extends CORE-MATH integration to binary64, following the
approach used for binary32. I prioritized functions with the lowest
accuracy. While binary32 allows exhaustive input accuracy checks using
CPU time, binary64 requires a combination of mathematical analysis and
statistical testing to ensure correctness.

For the former, I refer to the extensive work by Paul Zimmermann and
others [1], where they worked on analysis and the requirements for the
efficient and correctly rounded elementary functions implementation in
floating-point arithmetic as defined by the additional mathematical
operations of the IEEE 754-2019, and also added to the latest C
standard.

For statistical testing, I compare the current and CORE-MATH
implementations across various input ranges using uniformly distributed
random numbers to assess accuracy and confirm CORE-MATH correctness.

This patch introduces CORE-MATH implementations for acosh, asinh, atanh,
lgamma, tgamma, erf, and erfc, which previously exhibited the lowest
accuracy, particularly in non-default rounding modes. As before, the
CORE-MATH code was adapted to match glibc code style and internal math
definitions. I also separated data and common definitions to prevent
data definitions from being built in ifunc on x86_64 and to support code
maintainability.

Performance results are mixed: there are significant regressions for
erfc, minor regressions for acosh, and improvements for atanh, erf,
lgamma, and tgamma. Since the implementation depends on fma and other
floating-point primitives, further tuning may enable an ifunc variant
for ABIs that lack these features by default, such as x86_64.

Changes from v1:
* Imported acosh fixes.
* Consolidate common code definitions.

[1] https://inria.hal.science/hal-04474530
[2] https://members.loria.fr/PZimmermann/papers/accuracy.pdf

Adhemerval Zanella (12):
  math: Use acosh from CORE-MATH
  math: Use asinh from CORE-MATH
  math: Use atanh from CORE-MATH
  math: Consolidate acosh and asinh internal table
  math: Move atanh internal data to separate file
  math: Use lgamma from CORE-MATH
  math: Use tgamma from CORE-MATH
  math: Use erf from CORE-MATH
  math: Use erfc from CORE-MATH
  math: Consolidate internal erf/erfc tables
  math: Consolidate erf/erfc definitions
  math: Consolidate CORE-MATH double-double routines

 SHARED-FILES                             |   14 +
 math/Makefile                            |   13 +-
 math/auto-libm-test-in                   |    6 +
 math/auto-libm-test-out-erf              |  138 ++
 math/auto-libm-test-out-erfc             |   69 +
 sysdeps/i386/Makefile                    |   11 +-
 sysdeps/i386/fpu/libm-test-ulps          |   39 +
 sysdeps/ieee754/dbl-64/ddcoremath.h      |  213 +++
 sysdeps/ieee754/dbl-64/e_acosh.c         |  450 ++++-
 sysdeps/ieee754/dbl-64/e_atanh.c         |  276 ++-
 sysdeps/ieee754/dbl-64/e_gamma_r.c       | 1460 ++++++++++++--
 sysdeps/ieee754/dbl-64/e_lgamma_r.c      | 2236 +++++++++++++++++++---
 sysdeps/ieee754/dbl-64/gamma_product.c   |   46 -
 sysdeps/ieee754/dbl-64/gamma_productf.c  |    1 -
 sysdeps/ieee754/dbl-64/lgamma_neg.c      |  385 ----
 sysdeps/ieee754/dbl-64/lgamma_product.c  |   52 -
 sysdeps/ieee754/dbl-64/libm-test-ulps    |   84 +
 sysdeps/ieee754/dbl-64/math_config.h     |   36 +
 sysdeps/ieee754/dbl-64/math_err.c        |   31 +
 sysdeps/ieee754/dbl-64/s_asincosh_data.c |  124 ++
 sysdeps/ieee754/dbl-64/s_asincosh_data.h |   50 +
 sysdeps/ieee754/dbl-64/s_asinh.c         |  469 ++++-
 sysdeps/ieee754/dbl-64/s_atanh_data.c    |  243 +++
 sysdeps/ieee754/dbl-64/s_atanh_data.h    |   66 +
 sysdeps/ieee754/dbl-64/s_erf.c           |  420 ++--
 sysdeps/ieee754/dbl-64/s_erf_common.h    |  215 +++
 sysdeps/ieee754/dbl-64/s_erf_data.c      | 1557 +++++++++++++++
 sysdeps/ieee754/dbl-64/s_erf_data.h      |   56 +
 sysdeps/ieee754/dbl-64/s_erfc.c          |  805 ++++++--
 sysdeps/ieee754/dbl-64/s_erfc_data.c     |  355 ++++
 sysdeps/ieee754/dbl-64/s_erfc_data.h     |   49 +
 sysdeps/ieee754/flt-32/lgamma_negf.c     |    1 -
 sysdeps/ieee754/flt-32/lgamma_productf.c |    1 -
 sysdeps/ieee754/ldbl-96/gamma_product.c  |   44 -
 sysdeps/ieee754/ldbl-96/lgamma_product.c |   37 -
 35 files changed, 8343 insertions(+), 1709 deletions(-)
 create mode 100644 sysdeps/ieee754/dbl-64/ddcoremath.h
 delete mode 100644 sysdeps/ieee754/dbl-64/gamma_product.c
 delete mode 100644 sysdeps/ieee754/dbl-64/gamma_productf.c
 delete mode 100644 sysdeps/ieee754/dbl-64/lgamma_neg.c
 delete mode 100644 sysdeps/ieee754/dbl-64/lgamma_product.c
 create mode 100644 sysdeps/ieee754/dbl-64/libm-test-ulps
 create mode 100644 sysdeps/ieee754/dbl-64/s_asincosh_data.c
 create mode 100644 sysdeps/ieee754/dbl-64/s_asincosh_data.h
 create mode 100644 sysdeps/ieee754/dbl-64/s_atanh_data.c
 create mode 100644 sysdeps/ieee754/dbl-64/s_atanh_data.h
 create mode 100644 sysdeps/ieee754/dbl-64/s_erf_common.h
 create mode 100644 sysdeps/ieee754/dbl-64/s_erf_data.c
 create mode 100644 sysdeps/ieee754/dbl-64/s_erf_data.h
 create mode 100644 sysdeps/ieee754/dbl-64/s_erfc_data.c
 create mode 100644 sysdeps/ieee754/dbl-64/s_erfc_data.h
 delete mode 100644 sysdeps/ieee754/flt-32/lgamma_negf.c
 delete mode 100644 sysdeps/ieee754/flt-32/lgamma_productf.c
 delete mode 100644 sysdeps/ieee754/ldbl-96/gamma_product.c
 delete mode 100644 sysdeps/ieee754/ldbl-96/lgamma_product.c

-- 
2.43.0



More information about the Libc-alpha mailing list