[libc-commits] [libc] [llvm] [libc][math] Refactor log10, log1p, log2 implementation to header-onl… (PR #176089)

via libc-commits libc-commits at lists.llvm.org
Wed Jan 14 21:25:10 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Nico Weber (nico)

<details>
<summary>Changes</summary>

…y in src/__support/math folder.

Part of #<!-- -->147386

in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

---

Patch is 347.78 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/176089.diff


15 Files Affected:

- (modified) libc/shared/math.h (+3) 
- (added) libc/shared/math/log10.h (+22) 
- (added) libc/shared/math/log1p.h (+22) 
- (added) libc/shared/math/log2.h (+22) 
- (modified) libc/src/__support/math/CMakeLists.txt (+50) 
- (added) libc/src/__support/math/log10.h (+917) 
- (added) libc/src/__support/math/log1p.h (+1068) 
- (added) libc/src/__support/math/log2.h (+978) 
- (modified) libc/src/math/generic/CMakeLists.txt (+3-29) 
- (modified) libc/src/math/generic/log10.cpp (+2-899) 
- (modified) libc/src/math/generic/log1p.cpp (+2-1050) 
- (modified) libc/src/math/generic/log2.cpp (+2-960) 
- (modified) libc/test/shared/CMakeLists.txt (+3) 
- (modified) libc/test/shared/shared_math_test.cpp (+3) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+53-29) 


``````````diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 287f3aea1565a..b11186ae58149 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -65,6 +65,9 @@
 #include "math/ldexpf128.h"
 #include "math/ldexpf16.h"
 #include "math/log.h"
+#include "math/log10.h"
+#include "math/log1p.h"
+#include "math/log2.h"
 #include "math/rsqrtf.h"
 #include "math/rsqrtf16.h"
 #include "math/sin.h"
diff --git a/libc/shared/math/log10.h b/libc/shared/math/log10.h
new file mode 100644
index 0000000000000..6b3c71fb4df8e
--- /dev/null
+++ b/libc/shared/math/log10.h
@@ -0,0 +1,22 @@
+//===-- Shared log10 function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LOG10_H
+#define LLVM_LIBC_SHARED_MATH_LOG10_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/log10.h"
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+using math::log10;
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LOG10_H
diff --git a/libc/shared/math/log1p.h b/libc/shared/math/log1p.h
new file mode 100644
index 0000000000000..7d24718f6c415
--- /dev/null
+++ b/libc/shared/math/log1p.h
@@ -0,0 +1,22 @@
+//===-- Shared log1p function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LOG1P_H
+#define LLVM_LIBC_SHARED_MATH_LOG1P_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/log1p.h"
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+using math::log1p;
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LOG1P_H
diff --git a/libc/shared/math/log2.h b/libc/shared/math/log2.h
new file mode 100644
index 0000000000000..8609f4a81bbe9
--- /dev/null
+++ b/libc/shared/math/log2.h
@@ -0,0 +1,22 @@
+//===-- Shared log2 function ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LOG2_H
+#define LLVM_LIBC_SHARED_MATH_LOG2_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/log2.h"
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+using math::log2;
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LOG2_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 4139a1b1d3444..5be8d6412335b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1053,6 +1053,56 @@ add_header_library(
     libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  log10
+  HDRS
+    log10.h
+  DEPENDS
+    libc.src.__support.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
+    libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.polyeval
+    libc.src.__support.integer_literals
+    libc.src.__support.macros.optimization
+    libc.src.__support.math.common_constants
+    libc.src.__support.math.log_range_reduction
+)
+
+add_header_library(
+  log1p
+  HDRS
+    log1p.h
+  DEPENDS
+    libc.src.__support.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
+    libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.polyeval
+    libc.src.__support.integer_literals
+    libc.src.__support.macros.optimization
+    libc.src.__support.math.common_constants
+)
+
+add_header_library(
+  log2
+  HDRS
+    log2.h
+  DEPENDS
+    libc.src.__support.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
+    libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.polyeval
+    libc.src.__support.integer_literals
+    libc.src.__support.macros.optimization
+    libc.src.__support.math.common_constants
+    libc.src.__support.math.log_range_reduction
+)
+
 add_header_library(
   log_range_reduction
   HDRS
diff --git a/libc/src/__support/math/log10.h b/libc/src/__support/math/log10.h
new file mode 100644
index 0000000000000..70e6f0d341919
--- /dev/null
+++ b/libc/src/__support/math/log10.h
@@ -0,0 +1,917 @@
+//===-- Double-precision log10(x) function --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOG10_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LOG10_H
+
+#include "common_constants.h"
+#include "log_range_reduction.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/dyadic_float.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/common.h"
+#include "src/__support/integer_literals.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+namespace log10_internal {
+// 128-bit precision dyadic floating point numbers.
+using Float128 = typename fputil::DyadicFloat<128>;
+
+using LIBC_NAMESPACE::operator""_u128;
+
+using namespace common_constants_internal;
+using namespace math::log_range_reduction_internal;
+
+constexpr fputil::DoubleDouble LOG10_E = {0x1.95355baaafad3p-57,
+                                          0x1.bcb7b1526e50ep-2};
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+// A simple upper bound for the error of e_x * log(2) - log(r).
+constexpr double HI_ERR = 0x1.0p-85;
+
+// Extra errors from P is from using x^2 to reduce evaluation latency.
+constexpr double P_ERR = 0x1.0p-51;
+
+// log10(2) with 128-bit precision generated by SageMath with:
+// def format_hex(value):
+//     l = hex(value)[2:]
+//     n = 8
+//     x = [l[i:i + n] for i in range(0, len(l), n)]
+//     return "0x" + "'".join(x) + "_u128"
+// (s, m, e) = RealField(128)(2).log10().sign_exponent_mantissa();
+// print(format_hex(m));
+constexpr Float128 LOG10_2(Sign::POS, /*exponent=*/-129, /*mantissa=*/
+                           0x9a209a84'fbcff798'8f8959ac'0b7c9178_u128);
+
+alignas(16) constexpr LogRR LOG10_TABLE = {
+    // -log10(r) with 128-bit precision generated by SageMath with:
+    //
+    // for i in range(128):
+    //   r = 2^-8 * ceil( 2^8 * (1 - 2^(-8)) / (1 + i*2^(-7)) );
+    //   s, m, e = RealField(128)(r).log10().sign_mantissa_exponent();
+    //   print("{Sign::POS,", e, ", format_hex(m), "},");
+    /* .step_1 = */ {
+        {Sign::POS, 0, 0_u128},
+        {Sign::POS, -136, 0xdf3b5ebb'da7e186b'65af394f'e05eafd3_u128},
+        {Sign::POS, -135, 0xe01d4057'2f029c16'a8fb8d87'b30163b5_u128},
+        {Sign::POS, -134, 0xa8c1263a'c3f57eb3'6bb0170e'5bb5d630_u128},
+        {Sign::POS, -134, 0xe1e841bb'c26204e5'fc2ea6eb'0ea1370e_u128},
+        {Sign::POS, -133, 0x8dc2eb02'274d6ff4'dc8a199a'4bb63382_u128},
+        {Sign::POS, -133, 0xaacde920'361dd054'86b57ea6'10c7db33_u128},
+        {Sign::POS, -133, 0xc81618eb'15421bab'5f034a40'e6a2f09d_u128},
+        {Sign::POS, -133, 0xe59c7e66'c5fedb4b'594a31b2'c5cc891c_u128},
+        {Sign::POS, -133, 0xf477584f'97b654de'221efda5'8221904b_u128},
+        {Sign::POS, -132, 0x892e8219'75106e09'68a0dc47'567691c9_u128},
+        {Sign::POS, -132, 0x9841c66e'17dfe7da'10bc94f4'4d216b49_u128},
+        {Sign::POS, -132, 0x9fd7be33'18306cc5'e303ea7e'23c9d6fb_u128},
+        {Sign::POS, -132, 0xaf1cb35b'f494a8dd'ce697dba'a00d4c7d_u128},
+        {Sign::POS, -132, 0xbe8380a2'fa7eba5a'9c216079'dcf0ea96_u128},
+        {Sign::POS, -132, 0xc643c775'8283a271'75278940'eecfc3a9_u128},
+        {Sign::POS, -132, 0xd5de75ec'27e4fe68'2d3467d2'53e2d1fc_u128},
+        {Sign::POS, -132, 0xddb904e8'f1272a95'ead4055d'cdec7b22_u128},
+        {Sign::POS, -132, 0xed88f6bb'355fa196'e1e0dda0'b3d375a4_u128},
+        {Sign::POS, -132, 0xf57e8281'ade9d92d'38dc40c4'fe11e608_u128},
+        {Sign::POS, -131, 0x82c2941b'b20bbe1f'3bcdcfe7'b23976cd_u128},
+        {Sign::POS, -131, 0x86cb3663'2807cdcd'456350b0'bda452a6_u128},
+        {Sign::POS, -131, 0x8eeaa306'458b760a'78185dcc'37fda01a_u128},
+        {Sign::POS, -131, 0x93018395'12fc1168'307643ad'bbbde1b3_u128},
+        {Sign::POS, -131, 0x9b3dd1d5'50c41443'6c449d40'9f883fe3_u128},
+        {Sign::POS, -131, 0x9f6356aa'03c34389'8ea7b30c'8b4ad886_u128},
+        {Sign::POS, -131, 0xa7bd56cd'de5d76a2'961c6e69'0d8879b4_u128},
+        {Sign::POS, -131, 0xabf1ea3e'1d7bd7cf'042643ce'd81ec14a_u128},
+        {Sign::POS, -131, 0xb02b9af7'4c2f879e'4742fb3d'0b5cdd19_u128},
+        {Sign::POS, -131, 0xb8ae8671'b3d7dd6c'f7e2ab36'f09e9014_u128},
+        {Sign::POS, -131, 0xbcf7dabd'87c01afc'8d3fc634'85e7ff13_u128},
+        {Sign::POS, -131, 0xc1467f69'4d10a581'f3edc493'75fbc5a5_u128},
+        {Sign::POS, -131, 0xc9f3ef07'e1f3fc5e'5fcd7d0c'e937375f_u128},
+        {Sign::POS, -131, 0xce52d50b'94fa253a'58252dad'a9f06111_u128},
+        {Sign::POS, -131, 0xd2b74192'fae43777'62f01e5f'f43708ab_u128},
+        {Sign::POS, -131, 0xd72142a8'4ca85abd'481d9b31'31f52639_u128},
+        {Sign::POS, -131, 0xdb90e68b'8abf14af'b305ced1'419fe924_u128},
+        {Sign::POS, -131, 0xe48150cf'32888b9c'849266a8'5513dc6d_u128},
+        {Sign::POS, -131, 0xe90234c6'5a15e533'080ecf32'66b4dcf4_u128},
+        {Sign::POS, -131, 0xed88f6bb'355fa196'e1e0dda0'b3d375a4_u128},
+        {Sign::POS, -131, 0xf215a60b'6557943f'ce3537a3'a211b25b_u128},
+        {Sign::POS, -131, 0xf6a85251'3757dfbd'5dab6830'7fedefcd_u128},
+        {Sign::POS, -131, 0xffdfe15d'e3c01bac'1be2585c'279c50a5_u128},
+        {Sign::POS, -130, 0x8242724a'155219f3'18aa3021'71017dcb_u128},
+        {Sign::POS, -130, 0x849812d0'ccbb5cbd'abc7e698'502d43c0_u128},
+        {Sign::POS, -130, 0x86f0dab1'ab5822b6'c339089a'51663370_u128},
+        {Sign::POS, -130, 0x894cd27d'9f182c63'26f70b34'ce5cf201_u128},
+        {Sign::POS, -130, 0x8bac02e8'ac3e09ac'676f20a8'7ab433df_u128},
+        {Sign::POS, -130, 0x8e0e74ca'ae062e24'6db4169c'c4b83bc3_u128},
+        {Sign::POS, -130, 0x90743120'1c7f651a'cd3fdb2f'ad0d1fd6_u128},
+        {Sign::POS, -130, 0x92dd410a'd7bfe103'49d03e16'3250d1d4_u128},
+        {Sign::POS, -130, 0x9549add2'f8a3c7e0'9ec7dc02'd5e723b9_u128},
+        {Sign::POS, -130, 0x97b980e7'a743d71c'34698d03'a5442573_u128},
+        {Sign::POS, -130, 0x9a2cc3df'f7548556'0522904d'1e47f3de_u128},
+        {Sign::POS, -130, 0x9ca3807b'ca9fe93f'791a7264'6c87b976_u128},
+        {Sign::POS, -130, 0x9f1dc0a4'b9cea286'3826f190'd655d736_u128},
+        {Sign::POS, -130, 0xa19b8e6f'03b60e45'544ab3e4'8199b299_u128},
+        {Sign::POS, -130, 0xa41cf41a'83643487'be775fa8'2961114e_u128},
+        {Sign::POS, -130, 0xa6a1fc13'ad241953'45798e50'19e6c082_u128},
+        {Sign::POS, -130, 0xa92ab0f4'92b772bd'91fb1ed0'cdc4d1fb_u128},
+        {Sign::POS, -130, 0xabb71d85'ef05380d'818b8b9c'bbd17b72_u128},
+        {Sign::POS, -130, 0xae474cc0'397f0d4f'a50c2fea'60c5b3b2_u128},
+        {Sign::POS, -130, 0xb0db49cc'c1823c8e'58ea3498'0ad8b720_u128},
+        {Sign::POS, -130, 0xb3732006'd1fbbba5'4b5f7194'1be508a4_u128},
+        {Sign::POS, -130, 0xb60edafc'dd99ad1d'9e405fb8'bcb1ff1e_u128},
+        {Sign::POS, -130, 0xb60edafc'dd99ad1d'9e405fb8'bcb1ff1e_u128},
+        {Sign::POS, -130, 0xb8ae8671'b3d7dd6c'f7e2ab36'f09e9014_u128},
+        {Sign::POS, -130, 0xbb522e5d'bf37f63b'c6696396'40c305bb_u128},
+        {Sign::POS, -130, 0xbdf9def0'4cf980ff'a3dc9e46'4e98764b_u128},
+        {Sign::POS, -130, 0xc0a5a490'dea95b5e'ffd3256b'59fa9c59_u128},
+        {Sign::POS, -130, 0xc3558be0'85e3f4bc'b0a2d486'72a051a5_u128},
+        {Sign::POS, -130, 0xc3558be0'85e3f4bc'b0a2d486'72a051a5_u128},
+        {Sign::POS, -130, 0xc609a1bb'4aa98f59'acb2ca5d'4ca1c10e_u128},
+        {Sign::POS, -130, 0xc8c1f339'9ca7d33b'43690b9e'3cde0d02_u128},
+        {Sign::POS, -130, 0xcb7e8db1'cfe04827'18b1fd60'383f7e5a_u128},
+        {Sign::POS, -130, 0xce3f7eb9'a517c969'0248757e'5f45af3d_u128},
+        {Sign::POS, -130, 0xd104d427'de7fbcc4'7c4acd60'5be48bc1_u128},
+        {Sign::POS, -130, 0xd104d427'de7fbcc4'7c4acd60'5be48bc1_u128},
+        {Sign::POS, -130, 0xd3ce9c15'e10ec927'58ff6362'9a92652d_u128},
+        {Sign::POS, -130, 0xd69ce4e1'6303fcdd'6b49be3b'd8c89f10_u128},
+        {Sign::POS, -130, 0xd96fbd2e'2814c9cc'e6dd603a'881e9060_u128},
+        {Sign::POS, -130, 0xd96fbd2e'2814c9cc'e6dd603a'881e9060_u128},
+        {Sign::POS, -130, 0xdc4733e7'cbcbfc8c'89e281c9'8c1d705c_u128},
+        {Sign::POS, -130, 0xdf235843'9aa5dd12'dc0db7cf'0cce9f32_u128},
+        {Sign::POS, -130, 0xe20439c2'7a7c01b8'fdf1c5b8'46db9deb_u128},
+        {Sign::POS, -130, 0xe20439c2'7a7c01b8'fdf1c5b8'46db9deb_u128},
+        {Sign::POS, -130, 0xe4e9e832'e2da0c05'3dd7eab4'8869c402_u128},
+        {Sign::POS, -130, 0xe7d473b2'e5db8f2a'4e8fcc90'0b41daef_u128},
+        {Sign::POS, -130, 0xe7d473b2'e5db8f2a'4e8fcc90'0b41daef_u128},
+        {Sign::POS, -130, 0xeac3ecb2'4a3ac7b4'7593e1a9'e917359a_u128},
+        {Sign::POS, -130, 0xedb863f4'b73f982d'e7741396'b49e1ce5_u128},
+        {Sign::POS, -130, 0xedb863f4'b73f982d'e7741396'b49e1ce5_u128},
+        {Sign::POS, -130, 0xf0b1ea93'f34675a7'c8ba4f8f'47b85a5c_u128},
+        {Sign::POS, -130, 0xf3b09202'359f9787'7007c127'6821b705_u128},
+        {Sign::POS, -130, 0xf3b09202'359f9787'7007c127'6821b705_u128},
+        {Sign::POS, -130, 0xf6b46c0c'8c8fdea1'7ee19afe'6db7e324_u128},
+        {Sign::POS, -130, 0xf9bd8add'584687f0'edf54f37'f6d40420_u128},
+        {Sign::POS, -130, 0xf9bd8add'584687f0'edf54f37'f6d40420_u128},
+        {Sign::POS, -130, 0xfccc00fe'dba4e6fb'efe52ccf'03e7dee1_u128},
+        {Sign::POS, -130, 0xffdfe15d'e3c01bac'1be2585c'279c50a5_u128},
+        {Sign::POS, -130, 0xffdfe15d'e3c01bac'1be2585c'279c50a5_u128},
+        {Sign::POS, -129, 0x817c9fa6'43880404'e0b571f5'c91b0446_u128},
+        {Sign::POS, -129, 0x830c1742'7ea55eca'7178594b'ef2def59_u128},
+        {Sign::POS, -129, 0x830c1742'7ea55eca'7178594b'ef2def59_u128},
+        {Sign::POS, -129, 0x849e6196'487c1d1c'9a741bb1'71158d2a_u128},
+        {Sign::POS, -129, 0x849e6196'487c1d1c'9a741bb1'71158d2a_u128},
+        {Sign::POS, -129, 0x863388eb'55ebd295'1a618264'446cb495_u128},
+        {Sign::POS, -129, 0x87cb97c3'ff9eac18'71dbdbbe'c51d7657_u128},
+        {Sign::POS, -129, 0x87cb97c3'ff9eac18'71dbdbbe'c51d7657_u128},
+        {Sign::POS, -129, 0x896698dc'e4cff76c'abe0b522'230f7d14_u128},
+        {Sign::POS, -129, 0x896698dc'e4cff76c'abe0b522'230f7d14_u128},
+        {Sign::POS, -129, 0x8b04972e'9d4d3011'd28e8ada'fea703b4_u128},
+        {Sign::POS, -129, 0x8ca59def'7b5cefc5'208422d8'3be34b27_u128},
+        {Sign::POS, -129, 0x8ca59def'7b5cefc5'208422d8'3be34b27_u128},
+        {Sign::POS, -129, 0x8e49b895'5e3ffb8a'c385cf49'402af0e4_u128},
+        {Sign::POS, -129, 0x8e49b895'5e3ffb8a'c385cf49'402af0e4_u128},
+        {Sign::POS, -129, 0x8ff0f2d7'960a075c'da982a61'4e12c6dd_u128},
+        {Sign::POS, -129, 0x8ff0f2d7'960a075c'da982a61'4e12c6dd_u128},
+        {Sign::POS, -129, 0x919b58b0'd999bbc8'038401fc'1c1b5c2c_u128},
+        {Sign::POS, -129, 0x919b58b0'd999bbc8'038401fc'1c1b5c2c_u128},
+        {Sign::POS, -129, 0x9348f661'4f821394'a9b55d3f'16da746a_u128},
+        {Sign::POS, -129, 0x9348f661'4f821394'a9b55d3f'16da746a_u128},
+        {Sign::POS, -129, 0x94f9d870'aac256a5'088d2d14'73d4f7f5_u128},
+        {Sign::POS, -129, 0x94f9d870'aac256a5'088d2d14'73d4f7f5_u128},
+        {Sign::POS, -129, 0x96ae0bb0'5c35d5bd'7c1e117d'ea19e9e6_u128},
+        {Sign::POS, -129, 0x96ae0bb0'5c35d5bd'7c1e117d'ea19e9e6_u128},
+        {Sign::POS, -129, 0x98659d3d'd9b12532'336db063'0f536fb9_u128},
+        {Sign::POS, 0, 0_u128},
+    },
+    // -log10(r) for the second step, generated by SageMath with:
+    //
+    // for i in range(-2^6, 2^7 + 1):
+    //   r = 2^-16 * round( 2^16 / (1 + i*2^(-14)) );
+    //   s, m, e = RealField(128)(r).log10().sign_mantissa_exponent();
+    //   print("{Sign::POS," if s == -1 else "{Sign::NEG,", e, ",
+    //         format_hex(m), "},");
+    /* .step_2 = */
+    {
+        {Sign::NEG, -137, 0xdeca7290'13cd7c31'7f1ce002'fa34131b_u128},
+        {Sign::NEG, -137, 0xdb5475b4'4946d986'639afa08'5dd8b4c7_u128},
+        {Sign::NEG, -137, 0xd7de6b0e'10cab7d2'05512632'fe9a58cb_u128},
+        {Sign::NEG, -137, 0xd468529c'fc6fb395'b5380a99'53117d07_u128},
+        {Sign::NEG, -137, 0xd0f22c60'9e474741'70af2d7d'53be1f31_u128},
+        {Sign::NEG, -137, 0xcd7bf858'885dcae2'0ccd499c'49b74cc2_u128},
+        {Sign::NEG, -137, 0xca05b684'4cba73cf'5b51ddc3'987ebfb8_u128},
+        {Sign::NEG, -137, 0xc68f66e3'7d5f545a'49375f51'89b3782b_u128},
+        {Sign::NEG, -137, 0xc3190975'ac495b7a'f6e57738'865c712f_u128},
+        {Sign::NEG, -137, 0xbfa29e3a'6b70547e'ca02b10a'8c712acd_u128},
+        {Sign::NEG, -137, 0xbc2c2531'4cc6e6b6'78e50382'10208151_u128},
+        {Sign::NEG, -137, 0xb8b59e59'e23a9524'0fa099ec'd71ee0ea_u128},
+        {Sign::NEG, -137, 0xb53f09b3'bdb3be28'eeb445cc'b8fb09ed_u128},
+        {Sign::NEG, -137, 0xb1c8673e'71159b33'c352fff1'8a1c02fb_u128},
+        {Sign::NEG, -137, 0xae51b6f9'8e3e406e'7949e03e'cf9b390b_u128},
+        {Sign::NEG, -137, 0xaadaf8e4'a7069c6c'2681f33f'30aadedc_u128},
+        {Sign::NEG, -137, 0xa7642cff'4d4277d6'f01d5496'eea213b3_u128},
+        {Sign::NEG, -137, 0xa3ed5349'12c0751d'e92ef555'ff1de975_u128},
+        {Sign::NEG, -137, 0xa0766bc1'894a1022'eb0c7519'b3e7c1e0_u128},
+        {Sign::NEG, -137, 0x9c21b6e9'1e7f03a3'f60d204f'f0fe5296_u128},
+        {Sign::NEG, -137, 0x98aab049'1050bea8'125c19a4'f057c18b_u128},
+        {Sign::NEG, -137, 0x95339bd6'4cd953e7'7e9383ce'1bdf9575_u128},
+        {Sign::NEG, -137, 0x91bc7990'65cc57d6'bf274f4d'8f770253_u128},
+        {Sign::NEG, -137, 0x8e454976'ecd836ad'656bd9b7'58fe44ba_u128},
+        {Sign::NEG, -137, 0x8ace0b89'73a63413'bfdd2c7f'388fc014_u128},
+        {Sign::NEG, -137, 0x8756bfc7'8bda6ad0'83fbf6ed'936c493a_u128},
+        {Sign::NEG, -137, 0x83df6630'c713cc76'71bfa9a1'8bec01cc_u128},
+        {Sign::NEG, -137, 0x8067fec4'b6ec2111'f09d19f5'6dbfef72_u128},
+        {Sign::NEG, -138, 0xf9e11305'd9f00dad'4c422713'b1642228_u128},
+        {Sign::NEG, -138, 0xf2f20cd5'f58de39a'0c3c7c56'99b7a0a4_u128},
+        {Sign::NEG, -138, 0xec02eaf8'e3c656ff'b8db7c69'e3fa0797_u128},
+        {Sign::NEG, -138, 0xe513ad6d'c7a3a553'a083eb05'506ff7ed_u128},
+        {Sign::NEG, -138, 0xde245433'c425b5c5'c21595e7'45f1fa15_u128},
+        {Sign::NEG, -138, 0xd734df49'fc42189b'b9d5bcdb'fe719389_u128},
+        {Sign::NEG, -138, 0xd0454eaf'92e4068b'a17a1e85'e93461f4_u128},
+        {Sign::NEG, -138, 0xc955a263'aaec6016'e3537584'da333fda_u128},
+        {Sign::NEG, -138, 0xc265da65'6731ace5'00963177'f24682c2_u128},
+        {Sign::NEG, -138, 0xbb75f6b3'ea801b1e'4ac03734'7bcfc50e_u128},
+        {Sign::NEG, -138, 0xb485f74e'57997ec6'901a736a'4364cdfd_u128},
+        {Sign::NEG, -138, 0xad95dc33'd1355117'bb550acc'3b9d7247_u128},
+        {Sign::NEG, -138, 0xa6a5a563'7a00afdc'663cf2b2'7e8f1ffb_u128},
+        {Sign::NEG, -138, 0x9fb552dc'749e5cca'5f89bd08'feb39952_u128},
+        {Sign::NEG, -138, 0x98c4e49d'e3a6bcdd'23c2623c'73f494db_u128},
+        {Sign::NEG, -138, 0x91d45aa6'e9a7d7b0'4937d3b5'485af61e_u128},
+        {Sign::NEG, -138, 0x8ae3b4f6'a92556d9'df14214e'7a6d8111_u128},
+        {Sign::NEG, -138, 0x83f2f38c'44988544'bf7cfc14'999fb4bc_u128}...
[truncated]

``````````

</details>


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


More information about the libc-commits mailing list