[all-commits] [llvm/llvm-project] 78cc82: [libc][math] Implement double precision acos corre...

lntue via All-commits all-commits at lists.llvm.org
Thu May 8 20:23:31 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 78cc822aa6f5af0eda55089d22ba915b6d8e0216
      https://github.com/llvm/llvm-project/commit/78cc822aa6f5af0eda55089d22ba915b6d8e0216
  Author: lntue <lntue at google.com>
  Date:   2025-05-08 (Thu, 08 May 2025)

  Changed paths:
    M libc/config/darwin/arm/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/headers/math/index.rst
    M libc/include/math.yaml
    M libc/src/math/generic/CMakeLists.txt
    A libc/src/math/generic/acos.cpp
    M libc/src/math/generic/asin.cpp
    M libc/src/math/generic/asin_utils.h
    M libc/test/src/math/CMakeLists.txt
    A libc/test/src/math/acos_test.cpp
    M libc/test/src/math/smoke/CMakeLists.txt
    A libc/test/src/math/smoke/acos_test.cpp

  Log Message:
  -----------
  [libc][math] Implement double precision acos correctly rounded for all rounding modes. (#138308)

We reduce computation of `acos` to `asin` as follow:

When `|x| < 0.5`:
```math
acos(x) = \frac{\pi}{2} - asin(x).
```
For `0.5 <= |x| < 1`, let
```math
u = \frac{1 - \left| x \right|}{2},
```
then
```math
acos(x) = \begin{cases}
  2 \cdot asin \left( \sqrt{u} \right) &, 0.5 \leq x < 1 \\
  \pi - 2 \cdot asin \left( \sqrt{u} \right) &, -1 < x \leq 0.5 
\end{cases}
```



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