From patchwork Fri Sep 15 02:35:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 140098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp781185vqi; Thu, 14 Sep 2023 20:37:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYy71ShaZNP9otfnydh+CAljZgEWExK/0chDLPqfCpZBMpjexn8Uxln74ytSLHcjXwY0nR X-Received: by 2002:a05:6000:150:b0:31f:a503:c05c with SMTP id r16-20020a056000015000b0031fa503c05cmr335610wrx.38.1694749046098; Thu, 14 Sep 2023 20:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694749046; cv=none; d=google.com; s=arc-20160816; b=eUfRw33DwG4S2E3lzDKJwaOklvobXbnFVXqdROPJRI5HJZSr8qlmnTRIhQGjkr5NGy E1oJ7n1ZXdHXAg+UQqkaKLICx91TE8UR/3tBYMTD2kt54K5beUWWNjMLeIPhVBKBk2AK VE4fJlcc1HUzJPsaOza97D6ni+++b1+T30UHK4s41AU2zFf9rdjwJ3x2/1gYUH1VFTdk Odl/W4Ox1b6kp/0E+StGVTQtC9U5LktzpoQEk0cA6vGEdJBSZwQHNuA8RPeM+Wsg3jJ3 w6KQVqGyb5M7NnT0zGUQHaa+d+Yqx3ZSI6SwHfO8/a9RXrOOOMgbyjVAU0vQWTDgR+BX Z6xw== 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=CwlyvDPOmJ6OOvNpdnw7BaxPEtnzz0oDQ2vJDpQNy6k=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=o4mKnUukbr3zvpev3h4whUT14fqUaOoMXJaZXLm8M3Elu+I06+nrc6Q3fe2o2aXVjJ PeqS7s4JNzCPFBQ+S/yDNtVbgrP0rgQYbzzJ4fhAb20Ky6vsDnlMwpyVVO5Cw95k6Mh3 eU48hgBVgtOUu6kcsD0W10QbBbty9NqDaDrfGlcnVqf4xFcGAv2B0cEj7F9Vo+AXhdkt wkvlc+gKafru2SOZsoVQRLTYBPVxa2p4gTngag8O932hqBLwwV0qUWhMTP23xS0KvRQK PItieaDM+w2yY9xvOyH7D0LTCSoFNqmvcVn2frulL7n7naIKg2NI4UIERESooxwGfHjt EX4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="K6Mihj3/"; 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 t25-20020a05640203d900b0052ff7b17d3bsi2616686edw.136.2023.09.14.20.37.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 20:37:26 -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="K6Mihj3/"; 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 4A646382DC5E for ; Fri, 15 Sep 2023 02:54:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A646382DC5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694746447; bh=CwlyvDPOmJ6OOvNpdnw7BaxPEtnzz0oDQ2vJDpQNy6k=; 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=K6Mihj3/nqAvWpamCVqpFZFRK9gWr4F0/14mSU+Lw5x4CeS0v6uEV4F4B2Fd/qzsk SFxi38HXm9PyDTiLQmpTwTpcGVSMhw0w61WbVtXwvtahw3aiCTEK5Jj5VIX2wthA5P spVRbSm8B1lO0ctVIMoTqm9RHs11LIueeYsNq+0o= 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 B05BD38C8A07; Fri, 15 Sep 2023 02:37:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B05BD38C8A07 Received: from pps.filterd (m0247480.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38F2RFC0014037; Fri, 15 Sep 2023 02:37:07 GMT Received: from mxout26.s.uw.edu (mxout26.s.uw.edu [140.142.234.176]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3t47de39qx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 02:37:07 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout26.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 38F2ahJE017053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Sep 2023 19:36:43 -0700 X-Auth-Received: from localhost.localdomain ([10.154.75.179]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 38F2agoS001192 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 14 Sep 2023 19:36:43 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v13 36/40] libstdc++: Optimize is_unsigned trait performance Date: Thu, 14 Sep 2023 19:35:16 -0700 Message-ID: <20230915023640.75216-37-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230915023640.75216-1-kmatsui@gcc.gnu.org> References: <20230915022305.74083-1-kmatsui@gcc.gnu.org> <20230915023640.75216-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: Qm1F0WcoRIOOZj-YE-Kk_chZSZh1Imge X-Proofpoint-ORIG-GUID: Qm1F0WcoRIOOZj-YE-Kk_chZSZh1Imge X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_02,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 phishscore=0 mlxlogscore=756 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1034 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150021 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: , 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: 1776995061376064333 X-GMAIL-MSGID: 1777073175507983625 This patch optimizes the performance of the is_unsigned trait by dispatching to the new __is_unsigned built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_unsigned): Use __is_unsigned built-in trait. (is_unsigned_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 48d630a1478..f7d3815f332 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1001,10 +1001,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; /// is_unsigned +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unsigned) + template + struct is_unsigned + : public __bool_constant<__is_unsigned(_Tp)> + { }; +#else template struct is_unsigned : public __and_, __not_>>::type { }; +#endif /// @cond undocumented template @@ -3440,8 +3447,14 @@ template template inline constexpr bool is_signed_v = is_signed<_Tp>::value; + +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unsigned) +template + inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); +#else template inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; +#endif template inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);