Re: [PATCH 02/14] libstdc++: Optimize std::is_integral compilation performance

2024-01-10 Thread Jonathan Wakely
On Wed, 10 Jan 2024 at 19:48, Ken Matsui  wrote:
>
> This patch optimizes the compilation performance of std::is_integral
> by dispatching to the new __is_integral built-in trait.

OK for trunk (if the new built-in gets approved).


>
> libstdc++-v3/ChangeLog:
>
> * include/std/type_traits (is_integral): Use __is_integral
> built-in trait.
> (is_integral_v): Likewise.
>
> Signed-off-by: Ken Matsui 
> ---
>  libstdc++-v3/include/std/type_traits | 15 +++
>  1 file changed, 15 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/type_traits 
> b/libstdc++-v3/include/std/type_traits
> index 1cec0822b73..afa281d9cc4 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -334,6 +334,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  struct is_void
>  : public true_type { };
>
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_integral)
> +  /// is_integral
> +  template
> +struct is_integral
> +: public __bool_constant<__is_integral(_Tp)>
> +{ };
> +#else
>/// @cond undocumented
>template
>  struct __is_integral_helper
> @@ -461,6 +468,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  struct is_integral
>  : public __is_integral_helper<__remove_cv_t<_Tp>>::type
>  { };
> +#endif
>
>/// @cond undocumented
>template
> @@ -3221,8 +3229,15 @@ template 
>inline constexpr bool is_void_v = is_void<_Tp>::value;
>  template 
>inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
> +
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_integral)
> +template 
> +  inline constexpr bool is_integral_v = __is_integral(_Tp);
> +#else
>  template 
>inline constexpr bool is_integral_v = is_integral<_Tp>::value;
> +#endif
> +
>  template 
>inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
>
> --
> 2.43.0
>



[PATCH 02/14] libstdc++: Optimize std::is_integral compilation performance

2024-01-10 Thread Ken Matsui
This patch optimizes the compilation performance of std::is_integral
by dispatching to the new __is_integral built-in trait.

libstdc++-v3/ChangeLog:

* include/std/type_traits (is_integral): Use __is_integral
built-in trait.
(is_integral_v): Likewise.

Signed-off-by: Ken Matsui 
---
 libstdc++-v3/include/std/type_traits | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index 1cec0822b73..afa281d9cc4 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -334,6 +334,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct is_void
 : public true_type { };
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_integral)
+  /// is_integral
+  template
+struct is_integral
+: public __bool_constant<__is_integral(_Tp)>
+{ };
+#else
   /// @cond undocumented
   template
 struct __is_integral_helper
@@ -461,6 +468,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct is_integral
 : public __is_integral_helper<__remove_cv_t<_Tp>>::type
 { };
+#endif
 
   /// @cond undocumented
   template
@@ -3221,8 +3229,15 @@ template 
   inline constexpr bool is_void_v = is_void<_Tp>::value;
 template 
   inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
+
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_integral)
+template 
+  inline constexpr bool is_integral_v = __is_integral(_Tp);
+#else
 template 
   inline constexpr bool is_integral_v = is_integral<_Tp>::value;
+#endif
+
 template 
   inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
 
-- 
2.43.0