[all-commits] [llvm/llvm-project] c9ee6b: [libc][math] Implement cbrtf function correctly ro...
lntue via All-commits
all-commits at lists.llvm.org
Mon Jul 8 07:02:34 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c9ee6b1977e7dc88e3bd89b5e361c703721711fd
https://github.com/llvm/llvm-project/commit/c9ee6b1977e7dc88e3bd89b5e361c703721711fd
Author: lntue <35648136+lntue at users.noreply.github.com>
Date: 2024-07-08 (Mon, 08 Jul 2024)
Changed paths:
M libc/config/darwin/arm/entrypoints.txt
M libc/config/gpu/entrypoints.txt
M libc/config/linux/aarch64/entrypoints.txt
M libc/config/linux/arm/entrypoints.txt
M libc/config/linux/riscv/entrypoints.txt
M libc/config/linux/x86_64/entrypoints.txt
M libc/config/windows/entrypoints.txt
M libc/docs/math/index.rst
M libc/spec/stdc.td
M libc/src/__support/FPUtil/CMakeLists.txt
M libc/src/__support/FPUtil/FEnvImpl.h
M libc/src/math/CMakeLists.txt
A libc/src/math/cbrtf.h
M libc/src/math/generic/CMakeLists.txt
A libc/src/math/generic/cbrtf.cpp
M libc/test/src/math/CMakeLists.txt
A libc/test/src/math/cbrtf_test.cpp
M libc/test/src/math/exhaustive/CMakeLists.txt
A libc/test/src/math/exhaustive/cbrtf_test.cpp
M libc/test/src/math/exhaustive/exhaustive_test.h
M libc/test/src/math/smoke/CMakeLists.txt
A libc/test/src/math/smoke/cbrtf_test.cpp
M libc/utils/MPFRWrapper/MPFRUtils.cpp
M libc/utils/MPFRWrapper/MPFRUtils.h
Log Message:
-----------
[libc][math] Implement cbrtf function correctly rounded to all rounding modes. (#97936)
Fixes https://github.com/llvm/llvm-project/issues/92874
Algorithm: Let `x = (-1)^s * 2^e * (1 + m)`.
- Step 1: Range reduction: reduce the exponent with:
```
y = cbrt(x) = (-1)^s * 2^(floor(e/3)) * 2^((e % 3)/3) * (1 + m)^(1/3)
```
- Step 2: Use the first 4 bit fractional bits of `m` to look up for a
degree-7 polynomial approximation to:
```
(1 + m)^(1/3) ~ 1 + m * P(m).
```
- Step 3: Perform the multiplication:
```
2^((e % 3)/3) * (1 + m)^(1/3).
```
- Step 4: Check for exact cases to prevent rounding and clear
`FE_INEXACT` floating point exception.
- Step 5: Combine with the exponent and sign before converting down to
`float` and return.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list