From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7934) id 3AA393870898; Sat, 16 Dec 2023 17:00:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AA393870898 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702746050; bh=3z/sL2oAfFDhVzjoDGN7Ggzz0pi5+/y8j5JeGVG8j/c=; h=From:To:Subject:Date:From; b=V3zkEPfhKbXGnMeeLPgB510vSg7UNd8+ZJa1HsfyV7I+zO75YvwLvhUJ/Im9npaWG +IAgpL9Kkjjsysc0Kph/DKFwFCG0nhcSP6jK4/gdKl541VbL2ZfGdLq6P/o+L4TL9y aYcpdYRf2dnWb026fA6TA1VOZn4Ahucko1Uo/0K4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Ken Matsui To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-6631] libstdc++: Optimize std::is_object compilation performance X-Act-Checkin: gcc X-Git-Author: Ken Matsui X-Git-Refname: refs/heads/master X-Git-Oldrev: cdd4387c5b6aeace2e58318691a5880d29157db9 X-Git-Newrev: 4b111013654e745e8d73bd9614a15efbfd19ae8c Message-Id: <20231216170050.3AA393870898@sourceware.org> Date: Sat, 16 Dec 2023 17:00:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4b111013654e745e8d73bd9614a15efbfd19ae8c commit r14-6631-g4b111013654e745e8d73bd9614a15efbfd19ae8c Author: Ken Matsui Date: Thu Mar 30 02:13:49 2023 -0700 libstdc++: Optimize std::is_object compilation performance This patch optimizes the compilation performance of std::is_object by dispatching to the new __is_object built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_object): Use __is_object built-in trait. (is_object_v): Likewise. Signed-off-by: Ken Matsui Reviewed-by: Jonathan Wakely Diff: --- libstdc++-v3/include/std/type_traits | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b6d0441129b..2979d79a801 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -725,11 +725,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; /// is_object +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object) + template + struct is_object + : public __bool_constant<__is_object(_Tp)> + { }; +#else template struct is_object : public __not_<__or_, is_reference<_Tp>, is_void<_Tp>>>::type { }; +#endif template struct is_member_pointer; @@ -3280,8 +3287,15 @@ template inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; template inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; + +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object) +template + inline constexpr bool is_object_v = __is_object(_Tp); +#else template inline constexpr bool is_object_v = is_object<_Tp>::value; +#endif + template inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; template