[v2,4/4] libstdc++: Optimize std::remove_extent compilation performance

Message ID 20240214135252.1416047-4-kmatsui@gcc.gnu.org
State Unresolved
Headers
Series [v2,1/4] c++: Implement __add_pointer built-in trait |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Ken Matsui Feb. 14, 2024, 1:52 p.m. UTC
  This patch optimizes the compilation performance of std::remove_extent
by dispatching to the new __remove_extent built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (remove_extent): Use __remove_extent
	built-in trait.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
 libstdc++-v3/include/std/type_traits | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Patrick Palka Feb. 14, 2024, 8:21 p.m. UTC | #1
On Wed, 14 Feb 2024, Ken Matsui wrote:

> This patch optimizes the compilation performance of std::remove_extent
> by dispatching to the new __remove_extent built-in trait.
> 
> libstdc++-v3/ChangeLog:
> 
> 	* include/std/type_traits (remove_extent): Use __remove_extent
> 	built-in trait.

LGTM

> 
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
>  libstdc++-v3/include/std/type_traits | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
> index 3bde7cb8ba3..0fb1762186c 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -2064,6 +2064,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>    // Array modifications.
>  
>    /// remove_extent
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_extent)
> +  template<typename _Tp>
> +    struct remove_extent
> +    { using type = __remove_extent(_Tp); };
> +#else
>    template<typename _Tp>
>      struct remove_extent
>      { using type = _Tp; };
> @@ -2075,6 +2080,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>    template<typename _Tp>
>      struct remove_extent<_Tp[]>
>      { using type = _Tp; };
> +#endif
>  
>    /// remove_all_extents
>    template<typename _Tp>
> -- 
> 2.43.0
> 
>
  

Patch

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 3bde7cb8ba3..0fb1762186c 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2064,6 +2064,11 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Array modifications.
 
   /// remove_extent
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_extent)
+  template<typename _Tp>
+    struct remove_extent
+    { using type = __remove_extent(_Tp); };
+#else
   template<typename _Tp>
     struct remove_extent
     { using type = _Tp; };
@@ -2075,6 +2080,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct remove_extent<_Tp[]>
     { using type = _Tp; };
+#endif
 
   /// remove_all_extents
   template<typename _Tp>