From patchwork Thu Dec 7 05:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 174932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4574142vqy; Wed, 6 Dec 2023 21:45:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGY8venrOKeTqdTuFMAZAaeGTG2uVEC08RHOuZVF6G5eN61X8HpoweJ3HHQKNbVegCPR6Gt X-Received: by 2002:a05:622a:3c8:b0:425:4043:18a1 with SMTP id k8-20020a05622a03c800b00425404318a1mr2862464qtx.84.1701927950787; Wed, 06 Dec 2023 21:45:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701927950; cv=pass; d=google.com; s=arc-20160816; b=OfoXHs7yoWT6rBpEOYFGVH4tQIA/O61l1m4VbU419xZI5plEGTTIKh9Y2VqtdCq/nN WnIAGtIjAlp8bWrt1YLSdXc0Tepp/tKRJJkeeX6QFiE8YmsOgn5qbuZjAXK/TOx1f0aA 6MTWWzg+O4mXB+KPd9yNfwkKsHsYHma/XXbUCpV5YWEYtlDpl6pPqZczr58z19cFJw/9 hbHz1R96Tc8Yomfaau0QIKwFe+6a58Msldb7RG4n3hb6B7gfK2Su8u1CEu21OUzVQiUW tZqMX8RIqhWWP3UYaltYv7XBzmWIdHh9iMFCV0YuP73yH65hUqfmdSLCJXZJKBrYUCZe 3Rmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=ZneT6SXH05OMxm3tHIquPmgC3m04vrMHO4EAmh1RQDI=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=wDy86qqr6MrFCI9OK8mYyuJSDON0CtMEL2vll3h5geh6episL9VUAwuWso58ftTj82 S4RbwPwAN9MmclKFIUq3QlwVO7nUnUT+h/ue5lYvCfsRnZHUH25DyLarJ7f8hVLdMq4Z WVTm1H56UrtQwvZ0UMDQikCul3g8R8wVkO3kjKiEIR4oMyFxJHO5RkkALzYxxqsqbXf9 VgktDOx71W7CQ2XPWUc7j43wOXbrOa6ioNAuUILgpBfCN4N6vH8S8l3RXZYGcqno6E5c HxYmR3B9SrUMmMTZZGEnmD90fUEYW7ldEsq9uIKFJXhxQluz6x9EY25uh1GpmmRS/bn2 nRfg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uawNlKdK; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cf22-20020a05622a401600b0042552f02547si674732qtb.240.2023.12.06.21.45.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 21:45:50 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uawNlKdK; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8577E3857400 for ; Thu, 7 Dec 2023 05:45:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8577E3857400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701927950; bh=ZneT6SXH05OMxm3tHIquPmgC3m04vrMHO4EAmh1RQDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uawNlKdK8tIj9rDNpB8w+iYd0su7ep1JE7w8vySgo5caUcWVGPLD0zFKFmKURuHGI Sp+LLv1ynWIyDx+BKXXmgKsb80YU+t9gbkftO2VikPQbbLzsX7r45RUkDNKiHPVN/7 Gc5uUw9/A5opyTfwQlpnLVi3RQ6cAQCqvfcBNF2Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00641c01.pphosted.com (mx0a-00641c01.pphosted.com [205.220.165.146]) by sourceware.org (Postfix) with ESMTPS id 34AB5385B522; Thu, 7 Dec 2023 05:45:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34AB5385B522 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 34AB5385B522 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.165.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701927910; cv=none; b=YIPemgyRYckjejke7IdcFuaGhyuCmKebrDeVc0pBKMRyOy8gw7fHX8mvbx5Prf+yB2lcpoPQzECIvsOtPD07b/1vSsEDQzn9djzfPG7D5UOdu7wqTmP/xMx0rydxryqDYgb/vrE+hlsAeexe5pzXcqF2xECgmHvz6BSE1ha5scA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701927910; c=relaxed/simple; bh=bt2u5sC5TCWxnvMOAx5CAjGPc4bV3RZfiQsjg6wg8Ks=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=P7lAWnRUDQZkXo9M+Rn2k69dzkmepWyJxXavTWAO+wtCrdsedAUwd/yteJ3pZ94VQBE0CCmwLi27lYXMhlGFpZsckEzX+Ib+zQnpkq0aoFw+HyieD8dk8tSH8undVAMc6IdaW9nvhZlRkst1+vwduth20JsVBxk+IDFpvLhtcAA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247470.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B75dlGJ011905; Thu, 7 Dec 2023 05:45:08 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3uu035uyhn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Dec 2023 05:45:08 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout22.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3B75id3r015721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Dec 2023 21:44:39 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.75.142]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3B75adQA020981 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 6 Dec 2023 21:44:39 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v26 09/23] libstdc++: Optimize std::is_scoped_enum compilation performance Date: Wed, 6 Dec 2023 21:33:04 -0800 Message-ID: <20231207053633.1001720-10-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231207053633.1001720-1-kmatsui@gcc.gnu.org> References: <20231024020424.699427-1-kmatsui@gcc.gnu.org> <20231207053633.1001720-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: xC5sR_rk3g2JSCSd8zFTidqupsLB7Icq X-Proofpoint-ORIG-GUID: xC5sR_rk3g2JSCSd8zFTidqupsLB7Icq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-06_20,2023-12-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1034 mlxscore=0 suspectscore=0 impostorscore=0 mlxlogscore=794 lowpriorityscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312060159 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780601238448506991 X-GMAIL-MSGID: 1784600802742891173 This patch optimizes the compilation performance of std::is_scoped_enum by dispatching to the new __is_scoped_enum built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_scoped_enum): Use __is_scoped_enum built-in trait. (is_scoped_enum_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 2a1a0aa80ff..4a5068791af 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3602,6 +3602,12 @@ template /// True if the type is a scoped enumeration type. /// @since C++23 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum) + template + struct is_scoped_enum + : bool_constant<__is_scoped_enum(_Tp)> + { }; +# else template struct is_scoped_enum : false_type @@ -3613,11 +3619,17 @@ template struct is_scoped_enum<_Tp> : bool_constant { }; +# endif /// @ingroup variable_templates /// @since C++23 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_scoped_enum) + template + inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); +# else template inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; +# endif #endif #ifdef __cpp_lib_reference_from_temporary // C++ >= 23 && ref_{converts,constructs}_from_temp