From patchwork Fri Oct 13 21:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 152771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2165483vqb; Fri, 13 Oct 2023 14:34:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvznCKdgYCBz5lFwNHQhidHq9x/XTw3BFfxkyXY3/uoLcfenObc5DhscTjoYeMEhXrUTiU X-Received: by 2002:ad4:5b8f:0:b0:66d:3165:f976 with SMTP id 15-20020ad45b8f000000b0066d3165f976mr1886518qvp.14.1697232843502; Fri, 13 Oct 2023 14:34:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697232843; cv=pass; d=google.com; s=arc-20160816; b=bCVYsPpxZ22KVGUvxUOIFXVAYBkWqU3pv2xnFlpk0HyP208RpVm7eoLxn5RNfZdW8y rYgNIHqdTeG+j44lJw6fYforqgvlqGo/2u1jDMoz9vhyml6oGrnH1EKYJIMg4q7SxUQb 8exIJ8rul+4bAFpLA7hmexoMtLYq6j9sppidqRsY2YqJguqG+d7s4Jp2I3JkkoSM3u4A 6vuMeA0+78h4xtaMqbTav80GeGW4MJRn/aOoH4K8kw2BvJV5rEk9sTGtrXePKGjraXxf 8NhafhkdvtrZCLQPTW4HK8Egvlp8N1PT1Ac4AzcNBKvd4ZCwNf/cG7g+wOfAIsP3zHZb tKxg== 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:dmarc-filter:arc-filter:delivered-to:dkim-signature :dkim-filter; bh=1fhb3UCeN02Vpkdn4EKFUyJ55Q3UBgEbl435AnJkjqM=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=lDiEgurx+0castPFz067cq2xdZ/mWdo6n9b9L/MbZzzlF82P2/9MhupVK434yIA8Vi SsJKmDVcRX+ySz4PsrezMcRR/nEIxR3JfhJNO9NiULPvw7KLjH7tDLVKe73YGDGncP1v oOmnvt1luH+/E2lgoO5fMWMCkjz6Vy7D3HeReMXBvpBCbkcbJZ6oG+HUhQ1YrP/VyGBT oixHBH7FqY3smf+IBSKNdwUrMHMlD4SYOAC2MRrs+//MuURQevXznp3ieApwBtXg/OK7 r3yVkXtWaua4mFsHUNbph65ROas4RjIOxEQ4ja8IjmNGPLftzvQfOuc/br6K6n7aS7yU r6tg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BANAOIYQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z9-20020a0ce989000000b0065b02de7317si1875679qvn.573.2023.10.13.14.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 14:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BANAOIYQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 37F09385770B for ; Fri, 13 Oct 2023 21:34:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37F09385770B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697232843; bh=1fhb3UCeN02Vpkdn4EKFUyJ55Q3UBgEbl435AnJkjqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BANAOIYQrCQ6TIKbS14DpBeZw6q0IttJ0YdcWOvcyEYHscEv2u6Cia2GOcCNhn/Px hsmcgg0wUHJnUA6WTCyHts4SPND0bCpwTuItSBLYER8sZqQP5nTifBhfgTQrDNSifs 6XOO2A17GTNBGp3nuGGcidPpYb9e1BQLOol8QlFg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 96796385CC96; Fri, 13 Oct 2023 21:33:20 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 96796385CC96 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697232801; cv=none; b=hTkd2rJVXGavlZWSufObjt0eiIFgPc9J/JL4toe1BmkBp7v+piISQ4YhmD0HWgnrwJZQ7doExVAUbIhpIW29WTCBUfepLx9cH2lsbA/DVEiIoV/8o/zcZke0NAE2h2d05GyWauShEEtV+M2e61qPyHw7sJ1dd4zW0JB7vTQC4IE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697232801; c=relaxed/simple; bh=axxlZKKPGB8wuYsjw8SAimjjV9ZTlh7UjEpqEksZVtQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=xiXoMCmL0oRfCX8i5tq/MvjG/qC34VF7eIMCn2z1n/DnI1cGC2M1Fpm87dej1Mn7Wo3J3HG6055Tbje2+yl6lf2ZVyN54YTALd5P9vCJ/3OfZLk76Y4d0ZEA1dJWG9tLU5sG33seiZvUYD+54fZe5gmYf+HTKqnFNyznv4eWFT0= ARC-Authentication-Results: i=1; server2.sourceware.org DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 96796385CC96 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 Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39DLPpRx024422; Fri, 13 Oct 2023 21:33:20 GMT Received: from mxout23.cac.washington.edu (mxout23.cac.washington.edu [140.142.32.140]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3tqdep09gn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 21:33:20 +0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.234.157]) by mxout23.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 39DLWl8c017436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Oct 2023 14:32:47 -0700 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.19.18.191]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 39DLC9cZ009146 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 14:32:47 -0700 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 v18 32/40] libstdc++: Optimize is_arithmetic trait performance Date: Fri, 13 Oct 2023 14:04:28 -0700 Message-ID: <20231013211206.1215663-33-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231013211206.1215663-1-kmatsui@gcc.gnu.org> References: <20231011215049.1052142-1-kmatsui@gcc.gnu.org> <20231013211206.1215663-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: TtBQyx9uIo7kRQ1ocjhRsK6qr9ThJauu X-Proofpoint-GUID: TtBQyx9uIo7kRQ1ocjhRsK6qr9ThJauu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-13_12,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1034 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=546 mlxscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310130187 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_H2, 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776996488688417878 X-GMAIL-MSGID: 1779677626279025047 This patch optimizes the performance of the is_arithmetic trait by dispatching to the new __is_arithmetic built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_arithmetic): Use __is_arithmetic built-in trait. (is_arithmetic_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 3acd843f2f2..cc466e0f606 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -726,10 +726,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// is_arithmetic +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_arithmetic) + template + struct is_arithmetic + : public __bool_constant<__is_arithmetic(_Tp)> + { }; +#else template struct is_arithmetic : public __or_, is_floating_point<_Tp>>::type { }; +#endif /// is_fundamental template @@ -3344,8 +3351,14 @@ template inline constexpr bool is_reference_v<_Tp&&> = true; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_arithmetic) +template + inline constexpr bool is_arithmetic_v = __is_arithmetic(_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;