[libcxx-commits] [PATCH] D128215: [libc++] Reduces std::to_chars instantiations.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 20 10:40:33 PDT 2022


Mordante added a comment.

In D128215#3596983 <https://reviews.llvm.org/D128215#3596983>, @philnik wrote:

> Is there a reason to not just instantiate it for that largest integral type? Or `size_t` and the largest integral type to avoid using multiple registers for smaller types?

Yes we still support 32-bit platforms, using a 64-bit value there would give a performance penalty, especially on platforms with a small number or registers. Another reason why I prefer 32-bits is that I'm quite sure that division of a 32-bit value by a constant is more efficient than the division of a 64-bit value. (The compiler will transform it in a multiplication and a shift which IIRC always fits in a 64-bit register, when using a 32-bit value.) This is what we're doing for base 10.



================
Comment at: libcxx/include/type_traits:1024-1045
+template <class _Tp>
+using __make_32_64_or_128_bit_t = typename conditional<
+    is_signed<_Tp>::value,
+    typename conditional<
+        sizeof(_Tp) <= sizeof(int32_t), int32_t,
+        typename conditional<sizeof(_Tp) <= sizeof(int64_t), int64_t,
+#ifndef _LIBCPP_HAS_NO_INT128
----------------
philnik wrote:
> Could you put this into it's own header?
Yes I think that makes sense, but I first want to settle on a good name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128215



More information about the libcxx-commits mailing list