[libc] [llvm] Revert "[libc][NFC] Use user defined literals to build 128 and 256 bit constants." (PR #81771)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 09:53:26 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Guillaume Chatelet (gchatelet)

<details>
<summary>Changes</summary>

Reverts llvm/llvm-project#<!-- -->81746

---

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


16 Files Affected:

- (modified) libc/src/__support/integer_literals.h (+5-5) 
- (modified) libc/src/math/generic/CMakeLists.txt (+16-24) 
- (modified) libc/src/math/generic/exp.cpp (+14-10) 
- (modified) libc/src/math/generic/exp10.cpp (+10-10) 
- (modified) libc/src/math/generic/exp2.cpp (+10-10) 
- (modified) libc/src/math/generic/expm1.cpp (+15-11) 
- (modified) libc/src/math/generic/log.cpp (+627-630) 
- (modified) libc/src/math/generic/log10.cpp (+629-633) 
- (modified) libc/src/math/generic/log1p.cpp (+470-474) 
- (modified) libc/src/math/generic/log2.cpp (+624-627) 
- (modified) libc/test/src/__support/CMakeLists.txt (+1-3) 
- (modified) libc/test/src/__support/FPUtil/fpbits_test.cpp (+21-21) 
- (modified) libc/test/src/__support/integer_to_string_test.cpp (+13-26) 
- (modified) libc/test/src/__support/str_to_long_double_test.cpp (+27-21) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+8-16) 
- (modified) utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel (-2) 


``````````diff
diff --git a/libc/src/__support/integer_literals.h b/libc/src/__support/integer_literals.h
index ae09c5462a435b..c8e965c1a03a05 100644
--- a/libc/src/__support/integer_literals.h
+++ b/libc/src/__support/integer_literals.h
@@ -22,19 +22,19 @@
 namespace LIBC_NAMESPACE {
 
 LIBC_INLINE constexpr uint8_t operator""_u8(unsigned long long value) {
-  return static_cast<uint8_t>(value);
+  return value;
 }
 
 LIBC_INLINE constexpr uint16_t operator""_u16(unsigned long long value) {
-  return static_cast<uint16_t>(value);
+  return value;
 }
 
 LIBC_INLINE constexpr uint32_t operator""_u32(unsigned long long value) {
-  return static_cast<uint32_t>(value);
+  return value;
 }
 
 LIBC_INLINE constexpr uint64_t operator""_u64(unsigned long long value) {
-  return static_cast<uint64_t>(value);
+  return value;
 }
 
 namespace internal {
@@ -76,7 +76,7 @@ template <typename T, int base> struct DigitBuffer {
   // Returns the digit for a particular character.
   // Returns 255 if the character is invalid.
   LIBC_INLINE static constexpr uint8_t get_digit_value(const char c) {
-    const auto to_lower = [](char c) -> uint8_t { return c | 32; };
+    const auto to_lower = [](char c) { return c | 32; };
     const auto is_digit = [](char c) { return c >= '0' && c <= '9'; };
     const auto is_alpha = [](char c) {
       return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index ab7f5a91ab7bac..fdf383f070697e 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -622,8 +622,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
-    libc.include.math
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -634,9 +632,10 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.FPUtil.triple_double
-    libc.src.__support.integer_literals
     libc.src.__support.macros.optimization
+    libc.include.errno
     libc.src.errno.errno
+    libc.include.math
   COMPILE_OPTIONS
     -O3
 )
@@ -673,8 +672,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
-    libc.include.math
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -685,9 +682,10 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.FPUtil.triple_double
-    libc.src.__support.integer_literals
     libc.src.__support.macros.optimization
+    libc.include.errno
     libc.src.errno.errno
+    libc.include.math
   COMPILE_OPTIONS
     -O3
 )
@@ -733,8 +731,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
-    libc.include.math
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -745,9 +741,10 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.FPUtil.triple_double
-    libc.src.__support.integer_literals
     libc.src.__support.macros.optimization
+    libc.include.errno
     libc.src.errno.errno
+    libc.include.math
   COMPILE_OPTIONS
     -O3
 )
@@ -794,8 +791,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
-    libc.include.math
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -806,9 +801,10 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.FPUtil.triple_double
-    libc.src.__support.integer_literals
     libc.src.__support.macros.optimization
+    libc.include.errno
     libc.src.errno.errno
+    libc.include.math
   COMPILE_OPTIONS
     -O3
 )
@@ -1065,13 +1061,12 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .log_range_reduction
-    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.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
     libc.src.__support.macros.optimization
   COMPILE_OPTIONS
     -O3
@@ -1102,13 +1097,12 @@ add_entrypoint_object(
     ../log1p.h
   DEPENDS
     .common_constants
-    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.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
     libc.src.__support.macros.optimization
   COMPILE_OPTIONS
     -O3
@@ -1141,13 +1135,12 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .log_range_reduction
-    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.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
     libc.src.__support.macros.optimization
   COMPILE_OPTIONS
     -O3
@@ -1180,13 +1173,12 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .log_range_reduction
-    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.FPUtil.double_double
+    libc.src.__support.FPUtil.dyadic_float
     libc.src.__support.macros.optimization
   COMPILE_OPTIONS
     -O3
diff --git a/libc/src/math/generic/exp.cpp b/libc/src/math/generic/exp.cpp
index 42a4491131a04e..f23170f8ed4259 100644
--- a/libc/src/math/generic/exp.cpp
+++ b/libc/src/math/generic/exp.cpp
@@ -21,7 +21,6 @@
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/FPUtil/triple_double.h"
 #include "src/__support/common.h"
-#include "src/__support/integer_literals.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
@@ -32,7 +31,6 @@ using fputil::DoubleDouble;
 using fputil::TripleDouble;
 using Float128 = typename fputil::DyadicFloat<128>;
 using Sign = fputil::Sign;
-using LIBC_NAMESPACE::operator""_u128;
 
 // log2(e)
 constexpr double LOG2_E = 0x1.71547652b82fep+0;
@@ -99,15 +97,21 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
 // For |dx| < 2^-13 + 2^-30:
 //   | output - exp(dx) | < 2^-126.
 Float128 poly_approx_f128(const Float128 &dx) {
+  using MType = typename Float128::MantissaType;
+
   constexpr Float128 COEFFS_128[]{
-      {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
-      {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
-      {Sign::POS, -128, 0x80000000'00000000'00000000'00000000_u128}, // 0.5
-      {Sign::POS, -130, 0xaaaaaaaa'aaaaaaaa'aaaaaaaa'aaaaaaab_u128}, // 1/6
-      {Sign::POS, -132, 0xaaaaaaaa'aaaaaaaa'aaaaaaaa'aaaaaaab_u128}, // 1/24
-      {Sign::POS, -134, 0x88888888'88888888'88888888'88888889_u128}, // 1/120
-      {Sign::POS, -137, 0xb60b60b6'0b60b60b'60b60b60'b60b60b6_u128}, // 1/720
-      {Sign::POS, -140, 0xd00d00d0'0d00d00d'00d00d00'd00d00d0_u128}, // 1/5040
+      {Sign::POS, -127, MType({0, 0x8000000000000000})},                  // 1.0
+      {Sign::POS, -127, MType({0, 0x8000000000000000})},                  // 1.0
+      {Sign::POS, -128, MType({0, 0x8000000000000000})},                  // 0.5
+      {Sign::POS, -130, MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/6
+      {Sign::POS, -132,
+       MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/24
+      {Sign::POS, -134,
+       MType({0x8888888888888889, 0x8888888888888888})}, // 1/120
+      {Sign::POS, -137,
+       MType({0x60b60b60b60b60b6, 0xb60b60b60b60b60b})}, // 1/720
+      {Sign::POS, -140,
+       MType({0x00d00d00d00d00d0, 0xd00d00d00d00d00d})}, // 1/5040
   };
 
   Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
diff --git a/libc/src/math/generic/exp10.cpp b/libc/src/math/generic/exp10.cpp
index 72ece669765688..6b40f5561845d8 100644
--- a/libc/src/math/generic/exp10.cpp
+++ b/libc/src/math/generic/exp10.cpp
@@ -21,7 +21,6 @@
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/FPUtil/triple_double.h"
 #include "src/__support/common.h"
-#include "src/__support/integer_literals.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
@@ -32,7 +31,6 @@ using fputil::DoubleDouble;
 using fputil::TripleDouble;
 using Float128 = typename fputil::DyadicFloat<128>;
 using Sign = fputil::Sign;
-using LIBC_NAMESPACE::operator""_u128;
 
 // log2(10)
 constexpr double LOG2_10 = 0x1.a934f0979a371p+1;
@@ -101,15 +99,17 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
 // For |dx| < 2^-14:
 //   | output - 10^dx | < 1.5 * 2^-124.
 Float128 poly_approx_f128(const Float128 &dx) {
+  using MType = typename Float128::MantissaType;
+
   constexpr Float128 COEFFS_128[]{
-      {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
-      {Sign::POS, -126, 0x935d8ddd'aaa8ac16'ea56d62b'82d30a2d_u128},
-      {Sign::POS, -126, 0xa9a92639'e753443a'80a99ce7'5f4d5bdb_u128},
-      {Sign::POS, -126, 0x82382c8e'f1652304'6a4f9d7d'bf6c9635_u128},
-      {Sign::POS, -124, 0x12bd7609'fd98c44c'34578701'9216c7af_u128},
-      {Sign::POS, -127, 0x450a7ff4'7535d889'cc41ed7e'0d27aee5_u128},
-      {Sign::POS, -130, 0xd3f6b844'702d636b'8326bb91'a6e7601d_u128},
-      {Sign::POS, -130, 0x45b937f0'd05bb1cd'fa7b46df'314112a9_u128},
+      {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
+      {Sign::POS, -126, MType({0xea56d62b82d30a2d, 0x935d8dddaaa8ac16})},
+      {Sign::POS, -126, MType({0x80a99ce75f4d5bdb, 0xa9a92639e753443a})},
+      {Sign::POS, -126, MType({0x6a4f9d7dbf6c9635, 0x82382c8ef1652304})},
+      {Sign::POS, -124, MType({0x345787019216c7af, 0x12bd7609fd98c44c})},
+      {Sign::POS, -127, MType({0xcc41ed7e0d27aee5, 0x450a7ff47535d889})},
+      {Sign::POS, -130, MType({0x8326bb91a6e7601d, 0xd3f6b844702d636b})},
+      {Sign::POS, -130, MType({0xfa7b46df314112a9, 0x45b937f0d05bb1cd})},
   };
 
   Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
diff --git a/libc/src/math/generic/exp2.cpp b/libc/src/math/generic/exp2.cpp
index 83f545eb116bd3..01e66d1ae00f70 100644
--- a/libc/src/math/generic/exp2.cpp
+++ b/libc/src/math/generic/exp2.cpp
@@ -21,7 +21,6 @@
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/FPUtil/triple_double.h"
 #include "src/__support/common.h"
-#include "src/__support/integer_literals.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
@@ -32,7 +31,6 @@ using fputil::DoubleDouble;
 using fputil::TripleDouble;
 using Float128 = typename fputil::DyadicFloat<128>;
 using Sign = fputil::Sign;
-using LIBC_NAMESPACE::operator""_u128;
 
 // Error bounds:
 // Errors when using double precision.
@@ -90,15 +88,17 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
 // For |dx| < 2^-13 + 2^-30:
 //   | output - exp(dx) | < 2^-126.
 Float128 poly_approx_f128(const Float128 &dx) {
+  using MType = typename Float128::MantissaType;
+
   constexpr Float128 COEFFS_128[]{
-      {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
-      {Sign::POS, -128, 0xb17217f7'd1cf79ab'c9e3b398'03f2f6af_u128},
-      {Sign::POS, -128, 0x3d7f7bff'058b1d50'de2d60dd'9c9a1d9f_u128},
-      {Sign::POS, -132, 0xe35846b8'2505fc59'9d3b15d9'e7fb6897_u128},
-      {Sign::POS, -134, 0x9d955b7d'd273b94e'184462f6'bcd2b9e7_u128},
-      {Sign::POS, -137, 0xaec3ff3c'53398883'39ea1bb9'64c51a89_u128},
-      {Sign::POS, -138, 0x2861225f'345c396a'842c5341'8fa8ae61_u128},
-      {Sign::POS, -144, 0xffe5fe2d'109a319d'7abeb5ab'd5ad2079_u128},
+      {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
+      {Sign::POS, -128, MType({0xc9e3b39803f2f6af, 0xb17217f7d1cf79ab})},
+      {Sign::POS, -128, MType({0xde2d60dd9c9a1d9f, 0x3d7f7bff058b1d50})},
+      {Sign::POS, -132, MType({0x9d3b15d9e7fb6897, 0xe35846b82505fc59})},
+      {Sign::POS, -134, MType({0x184462f6bcd2b9e7, 0x9d955b7dd273b94e})},
+      {Sign::POS, -137, MType({0x39ea1bb964c51a89, 0xaec3ff3c53398883})},
+      {Sign::POS, -138, MType({0x842c53418fa8ae61, 0x2861225f345c396a})},
+      {Sign::POS, -144, MType({0x7abeb5abd5ad2079, 0xffe5fe2d109a319d})},
   };
 
   Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
diff --git a/libc/src/math/generic/expm1.cpp b/libc/src/math/generic/expm1.cpp
index 9f14a8c2068ec1..c1fb80309d7b46 100644
--- a/libc/src/math/generic/expm1.cpp
+++ b/libc/src/math/generic/expm1.cpp
@@ -22,7 +22,6 @@
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/FPUtil/triple_double.h"
 #include "src/__support/common.h"
-#include "src/__support/integer_literals.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
@@ -40,7 +39,6 @@ using fputil::DoubleDouble;
 using fputil::TripleDouble;
 using Float128 = typename fputil::DyadicFloat<128>;
 using Sign = fputil::Sign;
-using LIBC_NAMESPACE::operator""_u128;
 
 // log2(e)
 constexpr double LOG2_E = 0x1.71547652b82fep+0;
@@ -109,14 +107,20 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
 // For |dx| < 2^-13 + 2^-30:
 //   | output - exp(dx) | < 2^-126.
 Float128 poly_approx_f128(const Float128 &dx) {
+  using MType = typename Float128::MantissaType;
+
   constexpr Float128 COEFFS_128[]{
-      {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
-      {Sign::POS, -128, 0x80000000'00000000'00000000'00000000_u128}, // 0.5
-      {Sign::POS, -130, 0xaaaaaaaa'aaaaaaaa'aaaaaaaa'aaaaaaab_u128}, // 1/6
-      {Sign::POS, -132, 0xaaaaaaaa'aaaaaaaa'aaaaaaaa'aaaaaaab_u128}, // 1/24
-      {Sign::POS, -134, 0x88888888'88888888'88888888'88888889_u128}, // 1/120
-      {Sign::POS, -137, 0xb60b60b6'0b60b60b'60b60b60'b60b60b6_u128}, // 1/720
-      {Sign::POS, -140, 0xd00d00d0'0d00d00d'00d00d00'd00d00d0_u128}, // 1/5040
+      {Sign::POS, -127, MType({0, 0x8000000000000000})},                  // 1.0
+      {Sign::POS, -128, MType({0, 0x8000000000000000})},                  // 0.5
+      {Sign::POS, -130, MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/6
+      {Sign::POS, -132,
+       MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/24
+      {Sign::POS, -134,
+       MType({0x8888888888888889, 0x8888888888888888})}, // 1/120
+      {Sign::POS, -137,
+       MType({0x60b60b60b60b60b6, 0xb60b60b60b60b60b})}, // 1/720
+      {Sign::POS, -140,
+       MType({0x00d00d00d00d00d0, 0xd00d00d00d00d00d})}, // 1/5040
   };
 
   Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
@@ -142,6 +146,7 @@ std::ostream &operator<<(std::ostream &OS, const DoubleDouble &r) {
 // TODO(lntue): investigate triple-double precision implementation for this
 // step.
 Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
+  using MType = typename Float128::MantissaType;
   // Recalculate dx:
 
   double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -165,8 +170,7 @@ Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
   Float128 exp_mid = fputil::quick_mul(exp_mid1, exp_mid2);
 
   int hi = static_cast<int>(kd) >> 12;
-  Float128 minus_one{Sign::NEG, -127 - hi,
-                     0x80000000'00000000'00000000'00000000_u128};
+  Float128 minus_one{Sign::NEG, -127 - hi, MType({0, 0x8000000000000000})};
 
   Float128 exp_mid_m1 = fputil::quick_add(exp_mid, minus_one);
 
diff --git a/libc/src/math/generic/log.cpp b/libc/src/math/generic/log.cpp
index d770112599a98f..9edc52b8a8e24c 100644
--- a/libc/src/math/generic/log.cpp
+++ b/libc/src/math/generic/log.cpp
@@ -14,7 +14,6 @@
 #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/optimization.h" // LIBC_UNLIKELY
 
 #include "common_constants.h"
@@ -24,8 +23,8 @@ namespace LIBC_NAMESPACE {
 
 // 128-bit precision dyadic floating point numbers.
 using Float128 = typename fputil::DyadicFloat<128>;
+using MType = typename Float128::MantissaType;
 using Sign = fputil::Sign;
-using LIBC_NAMESPACE::operator""_u128;
 
 namespace {
 
@@ -35,152 +34,150 @@ 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-50;
 
-// log(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) + "_uint128"
-//  (s, m, e) = RealField(128)(2).log().sign_mantissa_exponent();
-//  print(format_hex(m));
+// log(2) with 128-bit prepcision generated by SageMath with:
+//   sage: (s, m, e) = RealField(128)(2).log().sign_mantissa_exponent();
+//   sage: print("MType({", hex(m % 2^64), ",", hex((m >> 64) % 2^64), "})");
 const Float128 LOG_2(Sign::POS, /*exponent=*/-128, /*mantissa=*/
-                     0xb17217f7'd1cf79ab'c9e3b398'03f2f6af_u128);
+                     MType({0xc9e3b39803f2f6af, 0xb17217f7d1cf79ab}));
 
 alignas(64) const LogRR LOG_TABLE = {
     // -log(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).log().sign_mantissa_exponent();
-    //   print("{Sign::POS,", e, ", format_hex(m), "},");
+    //   print("{Sign::POS,", e, ", MType({", hex(m % 2^64), ",", hex((m >> 64)
+    //   % 2^64),
+    //         "})},");
     /* .step_1= */ {
-        {Sign::POS, 0, 0_u128},
-        {Sign::POS, -134, 0x8080abac'46f38946'662d417c'ed007a46_u128},
-        {Sign::POS, -133, 0x8102b2c4'9ac23a4f'91d082dc'e3ddcd38_u128},
-        {Sign::POS, -133, 0xc2492946'4655f45c'da5f3cc0'b3251dbd_u128},
-        {Sign::POS, -132, 0x820aec4f'3a222380'b9e3aea6'c444ef07_u128},
-        {Sign::POS, -132, 0xa33576a1'6f1f4c64'521016bd'904dc968_u128},
-        {Sign::POS, -132, 0xc4a550a4'fd9a19a8'be97660a'23cc540d_u128},
-        {Sign::POS, -132, 0xe65b9e6e'ed965c36'e09f5fe2'058d6006_u128},
-        {Sign::POS, -131, 0x842cc5ac'f1d03445'1fecdfa8'19b96098_u128},
-        {Sign::POS, -131, 0x8cb9de8a'32ab368a'a7c98595'30a45153_u128},
-        {Sign::POS, -131, 0x9defad3e'8f73217a'976d3b5b'45f6ca0b_u128},
-        {Sign::POS, -131, 0xaf4ad26c'bc8e5be7'0e8b8b88'a14ff0ce_u128},
-        {Sign::POS, -131, 0xb8069857'560707a3'6a677b4c'8bec22e1_u128},
-        {Sign::POS, -131, 0xc99af2ea'ca4c4570'eaf51f66'692844ba_u128},
-        {Sign::POS, -131, 0xdb56446d'6ad8deff'a8112e35'a60e6375_u128},
-        {Sign::POS, -131, 0xe442c00d'e2591b47'196ab34c'e0bccd12_u128},
-        {Sign::POS, -131, 0xf639cc18'5088fe5d'4066e87f'2c0f7340_u128},
-        {Sign::POS, -131, 0xff4489ce'deab2ca6'c17bd40d'8d9291ec_u128},
-        {Sign::POS, -130, 0x88bc7411'3f23def1'9c5a0fe3'96f40f1e_u128},
-        {Sign::POS, -130, 0x8d515bf1'1fb94f1c'88713268'840cbcc0_u128},
-        {Sign::POS, -130, 0x968b0864'3409ceb6'65c0da50'6a088484_u128},
-        {Sign::POS, -130, 0x9b2fe580'ac80b17d'411a5b94'4aca8708_u128},
-        {Sign::POS, -130, 0xa489ec19'9dab06f2'a9fb6cf0'ecb411b7_u128},
-        {Sign::POS, -130, 0xa93f2f25'0dac67d1'cad2fb8d'48054ae0_u128},
-        {Sign::POS, -130, 0xb2ba75f4'6099cf8b'2c3c2e77'904afa78_u128},
-        {Sign::POS, -130, 0xb780945b'ab55dce4'34c7bc3d'32750fde_u128},
-        {Sign::POS, -130, 0xc11e0b2a'8d1e0ddb'9a631e83'0fd30904_u128},
-        {Sign::POS, -130, 0xc5f57f59'c7f46155'aa8b6997'...
[truncated]

``````````

</details>


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


More information about the llvm-commits mailing list