From patchwork Fri Sep 1 11:25:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 137385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c792:0:b0:3f2:4152:657d with SMTP id b18csp818565vqu; Fri, 1 Sep 2023 04:29:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFELCrzvrB+MASsu4vW3CZy5ulvYjYReLe671yTiIpLTAHmxzQGKF9r7aDAuM8XU/S/hEjo X-Received: by 2002:a19:6402:0:b0:500:b74b:e53 with SMTP id y2-20020a196402000000b00500b74b0e53mr1267742lfb.46.1693567763851; Fri, 01 Sep 2023 04:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693567763; cv=none; d=google.com; s=arc-20160816; b=NM1Un2VKPImH1hos441sKyDmuUFxmNPwwNId8ZE/bGQ1DnOFxD9dQA+iZUhtlQzLVI z1imiQS687C+Ehx6JtVFTdAxsuGB2dzVqpPFb3sb9jL7rs1vqlLCidhkw+C5Qotyfdpf SutNSbDLSw5El2HxaX3FoUcKXojUZlM97XxyNij8tXKbGb3UghmSmY51nP698u2ESQOD kkk/meMoH9MEHu/4Dspx6mLsQy6rBNdcgfxlTP2JIpIwEYrTNUT6TuxB+aetuClcbCh2 +AwXA5gu/+z2oZgiTyMPv6eLhMyQRYuEgPJb/xRoMsVz+jtS5D8uT5V2NajkYRJ725Oi Fmnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=2Nu+HAbF9cIjQvyQ2BUSF5xpXM+kj9F4w0P/BhV0h0o=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=MWzQ6aAsmEQqKuYerG4zr25Hd2kIOEJsou3hssK5WYUFAf58HK5l1bpvV3D44+lYEI +zbzuOYTMz1EFSREcLhNEctXTFoh5MmL9CJxi5W0qgjP4gkBG5CoYEpXN1Oz8jRI/J3/ DhBdZFvrTvuw/fjrsSJRcpRIwQOU6BD1TLVc5hD3J8SLJ6LZfnJG7glp683lFkfRA05I u4m7h5ShsT5PmOJVeXC/4Q1RcGvrGLlSLHuSWSlqee5AxwiuXivTtGpqnWI/h+RsCMAB cgc5+ahFtO3krFtFNjEAPWDEjFlHZqx6CHdPxZdA2caBn1Cqo6NXBQ7hePK4v+KvG7mo zQmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Yyi9xEnp; 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 t3-20020a05640203c300b0052c14588084si2393904edw.653.2023.09.01.04.29.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 04:29:23 -0700 (PDT) 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=Yyi9xEnp; 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 AEFC53856254 for ; Fri, 1 Sep 2023 11:28:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEFC53856254 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693567696; bh=2Nu+HAbF9cIjQvyQ2BUSF5xpXM+kj9F4w0P/BhV0h0o=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Yyi9xEnpFpc6RGJb6nU4TG9cEd0kzh36qA58HUBPRbg/4ZPSiSdHVSOCQbgKrHNOk Ab0I5Stj7H7pRRWGgzdfCw64//z9252AcQX1fYl/6fQ1NBAhSXXbKj+CNg2HKSAvm8 hCBKL+qrOkla8VCW9rUFtiqszhyjH9pRVj358gBg= 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 7522D3857347; Fri, 1 Sep 2023 11:27:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7522D3857347 Received: from pps.filterd (m0247472.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 381BDnST016948; Fri, 1 Sep 2023 11:27:27 GMT Received: from mxout24.cac.washington.edu (mxout24.cac.washington.edu [140.142.234.158]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3styeynjmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Sep 2023 11:27:27 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.132]) by mxout24.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 381BQuxZ013720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Sep 2023 04:26:56 -0700 X-Auth-Received: from localhost.localdomain ([10.154.74.234]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 381BPGtF005776 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 1 Sep 2023 04:26:56 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v5 3/4] libstdc++: Optimize is_fundamental trait performance Date: Fri, 1 Sep 2023 04:25:09 -0700 Message-ID: <20230901112510.1562-3-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230901112510.1562-1-kmatsui@gcc.gnu.org> References: <20230715045519.50684-1-kmatsui@gcc.gnu.org> <20230901112510.1562-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: MviQTKAMwoO51774Xvg_QkJQlUiFQMAT X-Proofpoint-GUID: MviQTKAMwoO51774Xvg_QkJQlUiFQMAT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-01_09,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 impostorscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 clxscore=1034 priorityscore=1501 mlxscore=0 suspectscore=0 mlxlogscore=554 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309010107 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NEUTRAL, TXREP 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: , X-Patchwork-Original-From: Ken Matsui via Gcc-patches From: Ken Matsui Reply-To: Ken Matsui Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775834511490858785 X-GMAIL-MSGID: 1775834511490858785 This patch optimizes the performance of the is_fundamental trait by dispatching to the new __is_arithmetic built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_fundamental_v): Use __is_arithmetic built-in trait. (is_fundamental): Likewise. Optimize the original implementation. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 7ebbe04c77b..cf24de2fcac 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -668,11 +668,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// is_fundamental +#if __has_builtin(__is_arithmetic) + template + struct is_fundamental + : public __bool_constant<__is_arithmetic(_Tp) + || is_void<_Tp>::value + || is_null_pointer<_Tp>::value> + { }; +#else template struct is_fundamental - : public __or_, is_void<_Tp>, - is_null_pointer<_Tp>>::type + : public __bool_constant::value + || is_void<_Tp>::value + || is_null_pointer<_Tp>::value> { }; +#endif /// is_object template @@ -3209,13 +3219,16 @@ template #if __has_builtin(__is_arithmetic) template inline constexpr bool is_arithmetic_v = __is_arithmetic(_Tp); +template + inline constexpr bool is_fundamental_v + = __is_arithmetic(_Tp) || is_void_v<_Tp> || is_null_pointer_v<_Tp>; #else template inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; -#endif - template inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; +#endif + template inline constexpr bool is_object_v = is_object<_Tp>::value; template