[libc-commits] [PATCH] D136495: [libc] add performance options for string to float

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Oct 24 11:36:25 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
michaelrj marked an inline comment as done.
Closed by commit rG551c7aed70ad: [libc] add performance options for string to float (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136495/new/

https://reviews.llvm.org/D136495

Files:
  libc/src/__support/str_to_float.h


Index: libc/src/__support/str_to_float.h
===================================================================
--- libc/src/__support/str_to_float.h
+++ libc/src/__support/str_to_float.h
@@ -108,8 +108,9 @@
   uint32_t clz = leading_zeroes<BitsType>(mantissa);
   mantissa <<= clz;
 
-  uint32_t exp2 = static_cast<uint32_t>(exp10_to_exp2(exp10)) + BITS_IN_MANTISSA +
-                  fputil::FloatProperties<T>::EXPONENT_BIAS - clz;
+  uint32_t exp2 = static_cast<uint32_t>(exp10_to_exp2(exp10)) +
+                  BITS_IN_MANTISSA + fputil::FloatProperties<T>::EXPONENT_BIAS -
+                  clz;
 
   // Multiplication
   const uint64_t *power_of_ten =
@@ -147,8 +148,10 @@
   }
 
   // Shifting to 54 bits for doubles and 25 bits for floats
-  BitsType msb = static_cast<BitsType>(high64(final_approx) >> (BITS_IN_MANTISSA - 1));
-  BitsType final_mantissa = static_cast<BitsType>(high64(final_approx) >>
+  BitsType msb =
+      static_cast<BitsType>(high64(final_approx) >> (BITS_IN_MANTISSA - 1));
+  BitsType final_mantissa =
+      static_cast<BitsType>(high64(final_approx) >>
                             (msb + BITS_IN_MANTISSA -
                              (fputil::FloatProperties<T>::MANTISSA_WIDTH + 3)));
   exp2 -= static_cast<uint32_t>(1 ^ msb); // same as !msb
@@ -208,7 +211,8 @@
   uint32_t clz = leading_zeroes<BitsType>(mantissa);
   mantissa <<= clz;
 
-  uint32_t exp2 = static_cast<uint32_t>(exp10_to_exp2(exp10)) + BITS_IN_MANTISSA +
+  uint32_t exp2 = static_cast<uint32_t>(exp10_to_exp2(exp10)) +
+                  BITS_IN_MANTISSA +
                   fputil::FloatProperties<long double>::EXPONENT_BIAS - clz;
 
   // Multiplication
@@ -576,12 +580,15 @@
     return;
   }
 
+#ifndef LLVM_LIBC_DISABLE_CLINGER_FAST_PATH
   if (!truncated) {
     if (clinger_fast_path<T>(mantissa, exp10, outputMantissa, outputExp2)) {
       return;
     }
   }
+#endif // LLVM_LIBC_DISABLE_CLINGER_FAST_PATH
 
+#ifndef LLVM_LIBC_DISABLE_EISEL_LEMIRE
   // Try Eisel-Lemire
   if (eisel_lemire<T>(mantissa, exp10, outputMantissa, outputExp2)) {
     if (!truncated) {
@@ -598,8 +605,11 @@
       }
     }
   }
+#endif // LLVM_LIBC_DISABLE_EISEL_LEMIRE
 
+#ifndef LLVM_LIBC_DISABLE_SIMPLE_DECIMAL_CONVERSION
   simple_decimal_conversion<T>(numStart, outputMantissa, outputExp2);
+#endif // LLVM_LIBC_DISABLE_SIMPLE_DECIMAL_CONVERSION
 
   return;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136495.470232.patch
Type: text/x-patch
Size: 2374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20221024/f294afc0/attachment.bin>


More information about the libc-commits mailing list