[libc] [llvm] libc][math] Refactor acosf implementation to header-only in src/__support/math folder. (PR #148411)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 12 23:11:04 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- libc/shared/math/acos.h libc/shared/math/acosf.h libc/shared/math/exp.h libc/shared/math/exp10.h libc/shared/math/exp10f.h libc/shared/math/exp10f16.h libc/shared/math/ldexpf.h libc/shared/math/ldexpf128.h libc/shared/math/ldexpf16.h libc/src/__support/math/acos.h libc/src/__support/math/acosf.h libc/src/__support/math/exp.h libc/src/__support/math/exp10.h libc/src/__support/math/exp10_float16_constants.h libc/src/__support/math/exp10f16.h libc/src/__support/math/exp10f16_utils.h libc/src/__support/math/exp10f_utils.h libc/src/__support/math/exp_constants.h libc/src/__support/math/exp_utils.h libc/src/__support/math/ldexpf.h libc/src/__support/math/ldexpf128.h libc/src/__support/math/ldexpf16.h libc/shared/math.h libc/src/__support/FPUtil/double_double.h libc/src/math/generic/acos.cpp libc/src/math/generic/acosf.cpp libc/src/math/generic/asin.cpp libc/src/math/generic/asinf.cpp libc/src/math/generic/atan2f.cpp libc/src/math/generic/atanf.cpp libc/src/math/generic/atanhf.cpp libc/src/math/generic/common_constants.cpp libc/src/math/generic/common_constants.h libc/src/math/generic/coshf.cpp libc/src/math/generic/exp.cpp libc/src/math/generic/exp10.cpp libc/src/math/generic/exp10f.cpp libc/src/math/generic/exp10f16.cpp libc/src/math/generic/exp10m1f16.cpp libc/src/math/generic/explogxf.h libc/src/math/generic/expxf16.h libc/src/math/generic/ldexpf.cpp libc/src/math/generic/ldexpf128.cpp libc/src/math/generic/ldexpf16.cpp libc/src/math/generic/powf.cpp libc/src/math/generic/sinhf.cpp libc/src/__support/math/asin_utils.h libc/src/__support/math/exp10f.h libc/src/__support/math/inv_trigf_utils.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/__support/math/acosf.h b/libc/src/__support/math/acosf.h
index 05c823300..941c39f6c 100644
--- a/libc/src/__support/math/acosf.h
+++ b/libc/src/__support/math/acosf.h
@@ -18,7 +18,6 @@
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-
namespace LIBC_NAMESPACE_DECL {
namespace math {
diff --git a/libc/src/__support/math/inv_trigf_utils.h b/libc/src/__support/math/inv_trigf_utils.h
index 8c5f7c44d..a2811c09e 100644
--- a/libc/src/__support/math/inv_trigf_utils.h
+++ b/libc/src/__support/math/inv_trigf_utils.h
@@ -137,7 +137,7 @@ LIBC_INLINE static constexpr double atan_eval(double x, unsigned i) {
// and approximate with Taylor polynomial:
// atan(q) ~ q - q^3/3 + q^5/5 - q^7/7 + q^9/9
LIBC_INLINE static constexpr double atan_eval_no_table(double num, double den,
- double k_over_16) {
+ double k_over_16) {
double num_r = fputil::multiply_add(den, -k_over_16, num);
double den_r = fputil::multiply_add(num, k_over_16, den);
double q = num_r / den_r;
diff --git a/libc/src/math/generic/atan2f.cpp b/libc/src/math/generic/atan2f.cpp
index bdc0ce5b9..0a768494b 100644
--- a/libc/src/math/generic/atan2f.cpp
+++ b/libc/src/math/generic/atan2f.cpp
@@ -8,7 +8,6 @@
#include "src/math/atan2f.h"
#include "hdr/fenv_macros.h"
-#include "src/__support/math/inv_trigf_utils.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/PolyEval.h"
@@ -18,6 +17,7 @@
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math/inv_trigf_utils.h"
#if defined(LIBC_MATH_HAS_SKIP_ACCURATE_PASS) && \
defined(LIBC_MATH_HAS_INTERMEDIATE_COMP_IN_FLOAT)
diff --git a/libc/src/math/generic/atanf.cpp b/libc/src/math/generic/atanf.cpp
index 7b609869a..d12456c59 100644
--- a/libc/src/math/generic/atanf.cpp
+++ b/libc/src/math/generic/atanf.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "src/math/atanf.h"
-#include "src/__support/math/inv_trigf_utils.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/PolyEval.h"
#include "src/__support/FPUtil/except_value_utils.h"
@@ -16,6 +15,7 @@
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math/inv_trigf_utils.h"
namespace LIBC_NAMESPACE_DECL {
``````````
</details>
https://github.com/llvm/llvm-project/pull/148411
More information about the llvm-commits
mailing list