[libc] [llvm] [libc][math] Refactor exp implementation to header-only in src/__support/math folder. (PR #148091)

LLVM Continuous Integration via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 09:23:24 PDT 2025


llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `libc-aarch64-ubuntu-fullbuild-dbg` running on `libc-aarch64-ubuntu` while building `libc,utils` at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/26777

<details>
<summary>Here is the relevant piece of the build log for the reference</summary>

```
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[19/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.pow.__internal__.dir/pow.cpp.o
[20/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.pow.dir/pow.cpp.o
[21/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.acoshf.__NO_ROUND_OPT.dir/acoshf.cpp.o
[22/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.expm1f.dir/expm1f.cpp.o
[23/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2f.__NO_ROUND_OPT.__internal__.dir/exp2f.cpp.o
[24/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.acoshf.dir/acoshf.cpp.o
[25/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2m1f.__internal__.dir/exp2m1f.cpp.o
[26/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp10.__NO_ROUND_OPT.dir/exp10.cpp.o
[27/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.coshf.__NO_ROUND_OPT.__internal__.dir/coshf.cpp.o
[28/1036] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp.__internal__.dir/exp.cpp.o
FAILED: libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp.__internal__.dir/exp.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc -isystem libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -fdiagnostics-color -g -D__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC -D__LIBC_USE_BUILTIN_ROUND -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -fpie -ffreestanding -DLIBC_FULL_BUILD -nostdlibinc -idirafter/usr/include -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -std=gnu++17 -MD -MT libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp.__internal__.dir/exp.cpp.o -MF libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp.__internal__.dir/exp.cpp.o.d -o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp.__internal__.dir/exp.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/math/generic/exp.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/math/generic/exp.cpp:10:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:70:25: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
static constexpr double poly_approx_d(double dx) {
                        ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:74:15: note: non-constexpr function 'multiply_add' cannot be used in a constant expression
  double c0 = fputil::multiply_add(dx, 0.5, 1.0);
              ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/FPUtil/multiply_add.h:60:20: note: declared here
LIBC_INLINE double multiply_add(double x, double y, double z) {
                   ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/math/generic/exp.cpp:10:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:88:31: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
static constexpr DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
                              ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:100:20: note: non-constexpr function 'polyeval<__llvm_libc_20_0_0_git::NumberPair<double>, __llvm_libc_20_0_0_git::NumberPair<double>, __llvm_libc_20_0_0_git::NumberPair<double>, __llvm_libc_20_0_0_git::NumberPair<double>, __llvm_libc_20_0_0_git::NumberPair<double>, __llvm_libc_20_0_0_git::NumberPair<double>, __llvm_libc_20_0_0_git::NumberPair<double>>' cannot be used in a constant expression
  DoubleDouble p = fputil::polyeval(dx, COEFFS[0], COEFFS[1], COEFFS[2],
                   ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/FPUtil/PolyEval.h:41:1: note: declared here
polyeval(const T &x, const T &a0, const Ts &...a) {
^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/math/generic/exp.cpp:10:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:109:27: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
static constexpr Float128 poly_approx_f128(const Float128 &dx) {
                          ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:121:16: note: non-constexpr function 'polyeval<__llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>, __llvm_libc_20_0_0_git::fputil::DyadicFloat<128>>' cannot be used in a constant expression
  Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
               ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/FPUtil/PolyEval.h:41:1: note: declared here
polyeval(const T &x, const T &a0, const Ts &...a) {
^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/math/generic/exp.cpp:10:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:130:27: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
static constexpr Float128 exp_f128(double x, double kd, int idx1, int idx2) {
                          ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/math/exp.h:133:15: note: non-constexpr function 'multiply_add' cannot be used in a constant expression
  double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
              ^

```

</details>

https://github.com/llvm/llvm-project/pull/148091


More information about the llvm-commits mailing list