[libc-commits] [libc] [llvm] [libc][math] Implement double-precision acosh (PR #199953)

via libc-commits libc-commits at lists.llvm.org
Fri Jul 3 06:33:08 PDT 2026


================
@@ -882,6 +882,72 @@ LIBC_INLINE_VAR constexpr Float128 BIG_COEFFS[4]{
 }
 #endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
+// Core range reduction + polynomial evaluation + Ziv rounding test for log.
+// Computes log(x_dd * 2^e_adj) where x_dd.hi is a normal positive finite
+// double. e_adj lets callers compute log(2^k * x) without forming 2^k * x
+// (e.g., to avoid overflow when k = 1 and x >= 2^1023).
+LIBC_INLINE double log_dd_core(fputil::DoubleDouble x_dd, int e_adj) {
+  using FPBits = fputil::FPBits<double>;
+  constexpr int EXP_BIAS = FPBits::EXP_BIAS;
+  constexpr int FRACTION_LEN = FPBits::FRACTION_LEN;
+
+  FPBits xhi_bits(x_dd.hi);
+  uint64_t xhi_frac = xhi_bits.get_mantissa();
+  uint64_t xdd_u = xhi_bits.uintval();
+
+  int idx = static_cast<int>((xhi_frac + (1ULL << (FRACTION_LEN - 8))) >>
----------------
lntue wrote:

Preserve or update the comments when refactoring.

https://github.com/llvm/llvm-project/pull/199953


More information about the libc-commits mailing list