From patchwork Wed Jan 10 09:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 18928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1018449dyi; Wed, 10 Jan 2024 11:50:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlrVnCDY3FC4oNBwr3ae2VXgY9AY0iJIXfT6xELvpL4Kzeh/ymUbyT20eAb8hx2z/J0siH X-Received: by 2002:a81:9a84:0:b0:5fa:f4dc:6504 with SMTP id r126-20020a819a84000000b005faf4dc6504mr4456ywg.50.1704916237991; Wed, 10 Jan 2024 11:50:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704916237; cv=pass; d=google.com; s=arc-20160816; b=rewiJg+N0TAEKqfJFWz6ME0LU64Gj3sXPzJSj140ZxZN/PBcAumjSNge/ujisqLbaC xAxwPjVT7qBSLBlfYqE0JsWQCvZGDSWzcOoSi90yCwMnEQvktdfYo9pPaL5xRRMHMKDw lUsg5QfQvJtzbz4jsiwwcXnpRPTb34QbYiqwgJsfGd1ydsef5qPQUR8d1tXTbnHdT2pS hB0UHJu/bKZ1n/mbnr/Lk9uppgrHHWALtqFHmPvXQPgfZxf36WyvqRRTRz5s2V4wLEBO Ko8nL85y8hBTEZ0en81Z5fDatvZYu/EOjAEF+t/kab+AfTJ2ygMKNpwxLR0B+t+TVoZl SX7Q== 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:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=m9UdPrFNRTviTZiiKPZgoFVRQCGNKXPOtBoKFvab8Bc=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=NfH9dFcA9sPB7W+QM6MYgiScq+qwPbGPzxWftHu1BU+geLKdGHzegbonX7jlJZRhOh TzMbWwUv7rOlnyYuuHOSCD9zwxGpOp2UcgdR6nGUl3+WS/apLuuLsdFZKsUQ/xAGIeua U7lwi0ceZsj48uOyGfFfcTIUVvcigSRLBmY7GTK/cJzwx91UG7S20SBCsF6MYHeoUAUA djrDAcVK4HfUL+Jz3fptwpfdlhlseZISrd5RkqlTQBjKvcyuEuCR/2GfBPmkDvKYedIv jLF0fewZpN7CCsRJiNmadF9JqTFSszLRPxNT5lGRkESHRTd+k5AukOMJu6z82mH4KyZa WD8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wXPfW6KW; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u13-20020a05620a454d00b007832046b287si2924037qkp.166.2024.01.10.11.50.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 11:50:37 -0800 (PST) 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=wXPfW6KW; 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 87CBB38582AE for ; Wed, 10 Jan 2024 19:50:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87CBB38582AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704916237; bh=m9UdPrFNRTviTZiiKPZgoFVRQCGNKXPOtBoKFvab8Bc=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=wXPfW6KWb0iKRwzutK/OTBFCNdavORs294wPeQANCwcnOvx2sUBmqVu40O0WOfH0L ZUumIq4p8lh01ABJYSvcJeDeMqfeOaG54BH3YEPDQiPRCgejmvfiFnBjlgNAGf0Om5 ctIB+4QGhRcRy/KuFyXVnbIrKxm4aihBY38XJUZg= 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 9E4573858030; Wed, 10 Jan 2024 19:41:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E4573858030 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 9E4573858030 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=1704915685; cv=none; b=XKeYi0fkwOWO/kEPrQOq/BHl/RMvmWrs4y+9bOq7mWePHsj0okRP66GVyJO4K36pdqN0vfhHVOC0WSfNL6G/K0gccnbzINC5auWUgHC6cVdulWTe04mMgfQBgjig86DHMSlrnJgK3f/u1bVM7S1UGqqsYz/R33VZluTZ5So/rmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704915685; c=relaxed/simple; bh=ByVPDZ0I/rEOU0KGf+27iYlz8IfJoYwX11TuFGuYdKQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=RENJxWxcrlBKiAD0+Ptn3SJyVTeuwHPAqcQutdvEY4VyQE9smqn97h7pTT8HBsVyWMOFvZD2LnCAQUy44rwXqQt1BM+mdzahZmX2jI30w5b+oNUGqZcNPqEm13n5hFfxjHW5lSrmS5vxQWY9nRZ9s0W1KDhbIxy7CiXSipdCvWg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247475.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40AJdWls018807; Wed, 10 Jan 2024 19:41:22 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vj0we0hpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 19:41:20 +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 40AJegs5006371 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 11:40:42 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 40AJefn9020412 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 11:40:41 -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 00/14] Optimize integral-related type traits Date: Wed, 10 Jan 2024 01:22:51 -0800 Message-ID: <20240110194031.2384005-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: pEyTjWwyxESijpCtJfj7pKlvARtEROk6 X-Proofpoint-GUID: pEyTjWwyxESijpCtJfj7pKlvARtEROk6 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=2024-01-10_10,2024-01-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 bulkscore=0 clxscore=1034 lowpriorityscore=0 suspectscore=0 mlxlogscore=233 impostorscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401100156 X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: 1787734249483610203 X-GMAIL-MSGID: 1787734249483610203 This patch series implements __is_integral, __is_floating_point, __is_arithmetic, __is_unsigned, __is_signed, and __is_scalar built-in traits and optimizes std::is_integral, std::is_floating_point, std::is_arithmetic, std::is_unsigned, std::is_signed, std::is_scalar, std::is_fundamental, and std::is_compound compilation performance. Here are the benchmark results: std::is_integral: https://github.com/ken-matsui/gcc-bench/blob/main/is_integral.md#wed-jan-10-112014-am-pst-2024 Time: -28.5606%, Peak Mem: -25.0022%, Total Mem: -22.4503% std::is_integral_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_integral_v.md#wed-jan-10-112014-am-pst-2024 Time: -44.9068%, Peak Mem: -37.046%, Total Mem: -36.3088% std::is_floating_point: https://github.com/ken-matsui/gcc-bench/blob/main/is_floating_point.md#wed-jan-10-112014-am-pst-2024 Time: -22.1413%, Peak Mem: -24.9831%, Total Mem: -22.4503% std::is_floating_point_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_floating_point_v.md#wed-jan-10-112014-am-pst-2024 Time: -44.9223%, Peak Mem: -37.0304%, Total Mem: -36.2869% std::is_arithmetic: https://github.com/ken-matsui/gcc-bench/blob/main/is_arithmetic.md#wed-jan-10-112014-am-pst-2024 Time: -67.5805%, Peak Mem: -55.3318%, Total Mem: -58.5106% std::is_arithmetic_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_arithmetic_v.md#wed-jan-10-112014-am-pst-2024 Time: -74.1939%, Peak Mem: -61.3623%, Total Mem: -64.8586% std::is_fundamental: https://github.com/ken-matsui/gcc-bench/blob/main/is_fundamental.md#wed-jan-10-112014-am-pst-2024 Time: -62.5392%, Peak Mem: -49.5002%, Total Mem: -53.3734% std::is_fundamental_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_fundamental_v.md#wed-jan-10-112014-am-pst-2024 Time: -56.9926%, Peak Mem: -49.3151%, Total Mem: -53.8913% std::is_compound: https://github.com/ken-matsui/gcc-bench/blob/main/is_compound.md#wed-jan-10-112014-am-pst-2024 Time: -56.3176%, Peak Mem: -45.7971%, Total Mem: -49.4637% std::is_compound_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_compound_v.md#wed-jan-10-112014-am-pst-2024 Time: -56.0783%, Peak Mem: -47.7484%, Total Mem: -52.5631% std::is_unsigned: https://github.com/ken-matsui/gcc-bench/blob/main/is_unsigned.md#wed-jan-10-112014-am-pst-2024 Time: -75.9165%, Peak Mem: -65.632%, Total Mem: -68.8883% std::is_unsigned_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_unsigned_v.md#wed-jan-10-112014-am-pst-2024 Time: -81.7237%, Peak Mem: -70.1175%, Total Mem: -73.4473% std::is_signed: https://github.com/ken-matsui/gcc-bench/blob/main/is_signed.md#wed-jan-10-112014-am-pst-2024 Time: -72.8341%, Peak Mem: -61.9239%, Total Mem: -64.5455% std::is_signed_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_signed_v.md#wed-jan-10-112014-am-pst-2024 Time: -79.9365%, Peak Mem: -66.9684%, Total Mem: -69.8372% std::is_scalar: https://github.com/ken-matsui/gcc-bench/blob/main/is_scalar.md#wed-jan-10-112014-am-pst-2024 Time: -87.2356%, Peak Mem: -79.0888%, Total Mem: -82.2095% std::is_scalar_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_scalar_v.md#wed-jan-10-112014-am-pst-2024 Time: -89.5349%, Peak Mem: -83.2528%, Total Mem: -85.6074% Ken Matsui (14): c++: Implement __is_integral built-in trait libstdc++: Optimize std::is_integral compilation performance c++: Implement __is_floating_point built-in trait libstdc++: Optimize std::is_floating_point compilation performance c++: Implement __is_arithmetic built-in trait libstdc++: Optimize std::is_arithmetic compilation performance libstdc++: Optimize std::is_fundamental compilation performance libstdc++: Optimize std::is_compound compilation performance c++: Implement __is_unsigned built-in trait libstdc++: Optimize std::is_unsigned compilation performance c++: Implement __is_signed built-in trait libstdc++: Optimize std::is_signed compilation performance c++: Implement __is_scalar built-in trait libstdc++: Optimize std::is_scalar compilation performance gcc/cp/constraint.cc | 18 ++++ gcc/cp/cp-trait.def | 6 ++ gcc/cp/semantics.cc | 65 +++++++++++- gcc/testsuite/g++.dg/ext/has-builtin-1.C | 18 ++++ gcc/testsuite/g++.dg/ext/is_arithmetic.C | 31 ++++++ gcc/testsuite/g++.dg/ext/is_floating_point.C | 43 ++++++++ gcc/testsuite/g++.dg/ext/is_integral.C | 49 +++++++++ gcc/testsuite/g++.dg/ext/is_scalar.C | 28 +++++ gcc/testsuite/g++.dg/ext/is_signed.C | 45 +++++++++ gcc/testsuite/g++.dg/ext/is_unsigned.C | 45 +++++++++ libstdc++-v3/include/std/type_traits | 101 ++++++++++++++++++- 11 files changed, 441 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_arithmetic.C create mode 100644 gcc/testsuite/g++.dg/ext/is_floating_point.C create mode 100644 gcc/testsuite/g++.dg/ext/is_integral.C create mode 100644 gcc/testsuite/g++.dg/ext/is_scalar.C create mode 100644 gcc/testsuite/g++.dg/ext/is_signed.C create mode 100644 gcc/testsuite/g++.dg/ext/is_unsigned.C