[v13,22/26] libstdc++: Optimize std::rank compilation performance
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Testing passed
|
Commit Message
This patch optimizes the compilation performance of std::rank
by dispatching to the new __rank built-in trait.
libstdc++-v3/ChangeLog:
* include/std/type_traits (rank): Use __rank built-in trait.
(rank_v): Likewise.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
libstdc++-v3/include/std/type_traits | 11 +++++++++++
1 file changed, 11 insertions(+)
@@ -1473,6 +1473,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
/// rank
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__rank)
+ template<typename _Tp>
+ struct rank
+ : public integral_constant<std::size_t, __rank(_Tp)> { };
+#else
template<typename>
struct rank
: public integral_constant<std::size_t, 0> { };
@@ -1484,6 +1489,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct rank<_Tp[]>
: public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
+#endif
/// extent
template<typename, unsigned _Uint = 0>
@@ -3579,12 +3585,17 @@ template <typename _Tp>
template <typename _Tp>
inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__rank)
+template <typename _Tp>
+ inline constexpr size_t rank_v = __rank(_Tp);
+#else
template <typename _Tp>
inline constexpr size_t rank_v = 0;
template <typename _Tp, size_t _Size>
inline constexpr size_t rank_v<_Tp[_Size]> = 1 + rank_v<_Tp>;
template <typename _Tp>
inline constexpr size_t rank_v<_Tp[]> = 1 + rank_v<_Tp>;
+#endif
template <typename _Tp, unsigned _Idx = 0>
inline constexpr size_t extent_v = 0;