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

LLVM Continuous Integration via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 2 13:07:36 PDT 2025


llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `libc-aarch64-ubuntu-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/104/builds/28282

<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)
...
[ RUN      ] LlvmLibcAddTestFloat16.SubnormalRange
[       OK ] LlvmLibcAddTestFloat16.SubnormalRange (8 ms)
[ RUN      ] LlvmLibcAddTestFloat16.NormalRange
[       OK ] LlvmLibcAddTestFloat16.NormalRange (358 ms)
[ RUN      ] LlvmLibcAddTestFloat128.SubnormalRange
[       OK ] LlvmLibcAddTestFloat128.SubnormalRange (1945 ms)
[ RUN      ] LlvmLibcAddTestFloat128.NormalRange
[       OK ] LlvmLibcAddTestFloat128.NormalRange (1956 ms)
Ran 10 tests.  PASS: 10  FAIL: 0
[1112/1119] Building CXX object libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o
FAILED: libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.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/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 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -std=gnu++17 -MD -MT libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o -MF libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o.d -o libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp:9:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math.h:32:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math/atanhf16.h:16:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:112:36: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
LIBC_INLINE static constexpr float log_eval_f(float x) {
                                   ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:137:14: note: non-constexpr function 'multiply_add' cannot be used in a constant expression
  float c1 = fputil::multiply_add(dx, COEFFS[1], COEFFS[0]);
             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/multiply_add.h:50:19: note: declared here
LIBC_INLINE float multiply_add(float x, float y, float z) {
                  ^
1 error generated.
[1113/1119] Building CXX object libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o
FAILED: libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.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/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 -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -std=gnu++17 -MD -MT libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o -MF libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o.d -o libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp:9:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math.h:32:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math/atanhf16.h:16:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:112:36: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
LIBC_INLINE static constexpr float log_eval_f(float x) {
                                   ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:137:14: note: non-constexpr function 'multiply_add' cannot be used in a constant expression
  float c1 = fputil::multiply_add(dx, COEFFS[1], COEFFS[0]);
             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/multiply_add.h:50:19: note: declared here
LIBC_INLINE float multiply_add(float x, float y, float z) {
                  ^
1 error generated.
[1114/1119] Running unit test libc.test.src.math.sqrtl_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcSqrtTest.DenormalValues
[       OK ] LlvmLibcSqrtTest.DenormalValues (4112 ms)
[ RUN      ] LlvmLibcSqrtTest.NormalRange
[       OK ] LlvmLibcSqrtTest.NormalRange (2147 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[1115/1119] Running unit test libc.test.src.math.sub_same_type_test.__unit__
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcAddTestFloat16.SubnormalRange
[       OK ] LlvmLibcAddTestFloat16.SubnormalRange (8 ms)
[ RUN      ] LlvmLibcAddTestFloat16.NormalRange
[       OK ] LlvmLibcAddTestFloat16.NormalRange (358 ms)
[ RUN      ] LlvmLibcAddTestFloat128.SubnormalRange
[       OK ] LlvmLibcAddTestFloat128.SubnormalRange (1945 ms)
[ RUN      ] LlvmLibcAddTestFloat128.NormalRange
[       OK ] LlvmLibcAddTestFloat128.NormalRange (1956 ms)
Ran 10 tests.  PASS: 10  FAIL: 0
[1112/1119] Building CXX object libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o
FAILED: libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.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/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 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -std=gnu++17 -MD -MT libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o -MF libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o.d -o libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__NO_ROUND_OPT.__build__.dir/shared_math_test.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp:9:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math.h:32:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math/atanhf16.h:16:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:112:36: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
LIBC_INLINE static constexpr float log_eval_f(float x) {
                                   ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:137:14: note: non-constexpr function 'multiply_add' cannot be used in a constant expression
  float c1 = fputil::multiply_add(dx, COEFFS[1], COEFFS[0]);
             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/multiply_add.h:50:19: note: declared here
LIBC_INLINE float multiply_add(float x, float y, float z) {
                  ^
1 error generated.
[1113/1119] Building CXX object libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o
FAILED: libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.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/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 -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -std=gnu++17 -MD -MT libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o -MF libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o.d -o libc/test/shared/CMakeFiles/libc.test.shared.shared_math_test.__unit__.__build__.dir/shared_math_test.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/shared/shared_math_test.cpp:9:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math.h:32:
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/shared/math/atanhf16.h:16:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:112:36: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
LIBC_INLINE static constexpr float log_eval_f(float x) {
                                   ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/math/atanhf16.h:137:14: note: non-constexpr function 'multiply_add' cannot be used in a constant expression
  float c1 = fputil::multiply_add(dx, COEFFS[1], COEFFS[0]);
             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/multiply_add.h:50:19: note: declared here
LIBC_INLINE float multiply_add(float x, float y, float z) {
                  ^
1 error generated.
[1114/1119] Running unit test libc.test.src.math.sqrtl_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcSqrtTest.DenormalValues
[       OK ] LlvmLibcSqrtTest.DenormalValues (4112 ms)
[ RUN      ] LlvmLibcSqrtTest.NormalRange
[       OK ] LlvmLibcSqrtTest.NormalRange (2147 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[1115/1119] Running unit test libc.test.src.math.sub_same_type_test.__unit__

```

</details>

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


More information about the llvm-commits mailing list