[all-commits] [llvm/llvm-project] bc7a3b: [libc][math] Implement powf function correctly rou...
lntue via All-commits
all-commits at lists.llvm.org
Mon Nov 6 13:54:38 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bc7a3bd864be696217c4d11eddf16bed7646b60f
https://github.com/llvm/llvm-project/commit/bc7a3bd864be696217c4d11eddf16bed7646b60f
Author: lntue <35648136+lntue at users.noreply.github.com>
Date: 2023-11-06 (Mon, 06 Nov 2023)
Changed paths:
M libc/config/darwin/arm/entrypoints.txt
M libc/config/linux/aarch64/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/math/generic/CMakeLists.txt
M libc/src/math/generic/common_constants.cpp
M libc/src/math/generic/common_constants.h
M libc/src/math/generic/exp10f.cpp
A libc/src/math/generic/exp10f_impl.h
M libc/src/math/generic/exp2f.cpp
A libc/src/math/generic/exp2f_impl.h
M libc/src/math/generic/log2f.cpp
A libc/src/math/generic/powf.cpp
M libc/test/UnitTest/FPMatcher.h
M libc/test/src/math/CMakeLists.txt
A libc/test/src/math/powf_test.cpp
M libc/test/src/math/smoke/CMakeLists.txt
A libc/test/src/math/smoke/powf_test.cpp
M libc/utils/MPFRWrapper/MPFRUtils.cpp
M libc/utils/MPFRWrapper/MPFRUtils.h
Log Message:
-----------
[libc][math] Implement powf function correctly rounded to all rounding modes. (#71188)
We compute `pow(x, y)` using the formula
```
pow(x, y) = x^y = 2^(y * log2(x))
```
We follow similar steps as in `log2f(x)` and `exp2f(x)`, by breaking
down into `hi + mid + lo` parts, in which `hi` parts are computed using
the exponent field directly, `mid` parts will use look-up tables, and
`lo` parts are approximated by polynomials.
We add some speedup for common use-cases:
```
pow(2, y) = exp2(y)
pow(10, y) = exp10(y)
pow(x, 2) = x * x
pow(x, 1/2) = sqrt(x)
pow(x, -1/2) = rsqrt(x) - to be added
```
More information about the All-commits
mailing list