[libc-commits] [libc] [libc] Fix compilation of new trig functions (PR #111987)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Oct 11 05:23:00 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/111987

None

>From f2e0a33124726498185820beb7d2f3ea3de2b520 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 11 Oct 2024 07:22:15 -0500
Subject: [PATCH] [libc] Fix compilation of new trig functions

---
 libc/src/math/generic/cos.cpp                         | 4 ++--
 libc/src/math/generic/range_reduction_double_common.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libc/src/math/generic/cos.cpp b/libc/src/math/generic/cos.cpp
index 923ea96852d889..618a96520848a4 100644
--- a/libc/src/math/generic/cos.cpp
+++ b/libc/src/math/generic/cos.cpp
@@ -99,7 +99,7 @@ LLVM_LIBC_FUNCTION(double, cos, (double x)) {
   // Fast look up version, but needs 256-entry table.
   // -sin(k * pi/128) = sin((k + 128) * pi/128)
   // cos(k * pi/128) = sin(k * pi/128 + pi/2) = sin((k + 64) * pi/128).
-  DoubleDouble msin_k = SIN_K_PI_OVER_128[(k + 128) & 255];
+  DoubleDouble sin_k = SIN_K_PI_OVER_128[(k + 128) & 255];
   DoubleDouble cos_k = SIN_K_PI_OVER_128[(k + 64) & 255];
 #endif // LIBC_MATH_HAS_SMALL_TABLES
 
@@ -108,7 +108,7 @@ LLVM_LIBC_FUNCTION(double, cos, (double x)) {
   // Then cos(x) = cos((k * pi/128 + y)
   //             = cos(y) * cos(k*pi/128) - sin(y) * sin(k*pi/128)
   DoubleDouble cos_k_cos_y = fputil::quick_mult(cos_y, cos_k);
-  DoubleDouble msin_k_sin_y = fputil::quick_mult(sin_y, msin_k);
+  DoubleDouble msin_k_sin_y = fputil::quick_mult(sin_y, sin_k);
 
   DoubleDouble rr = fputil::exact_add<false>(cos_k_cos_y.hi, msin_k_sin_y.hi);
   rr.lo += msin_k_sin_y.lo + cos_k_cos_y.lo;
diff --git a/libc/src/math/generic/range_reduction_double_common.h b/libc/src/math/generic/range_reduction_double_common.h
index e23bbff144bee8..f32bcda70d9b41 100644
--- a/libc/src/math/generic/range_reduction_double_common.h
+++ b/libc/src/math/generic/range_reduction_double_common.h
@@ -278,7 +278,7 @@ struct LargeRangeReduction {
   DoubleDouble y_mid;
 };
 
-static Float128 range_reduction_small_f128(double x) {
+[[maybe_unused]] static Float128 range_reduction_small_f128(double x) {
   constexpr Float128 PI_OVER_128_F128 = {
       Sign::POS, -133, 0xc90f'daa2'2168'c234'c4c6'628b'80dc'1cd1_u128};
   constexpr double ONE_TWENTY_EIGHT_OVER_PI_D = 0x1.45f306dc9c883p5;



More information about the libc-commits mailing list