From patchwork Fri Oct 13 22:37:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 15359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2191091vqb; Fri, 13 Oct 2023 15:40:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHinOtj/p+qus1D27SSS4qL00ZO7dPRt4Gygy6ivStFIh2bl6FFABc+K1lRyV8V66/7KRGG X-Received: by 2002:a05:622a:1709:b0:412:24e6:a485 with SMTP id h9-20020a05622a170900b0041224e6a485mr26409078qtk.2.1697236848789; Fri, 13 Oct 2023 15:40:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697236848; cv=pass; d=google.com; s=arc-20160816; b=C2eAef1da1q6M3P8+Z4lTjNnlZjRanGBh/wH1kcZaknRQ+Wcg2lzae5motPvee9opK 27PU3UnwqKQw6ayA/xMzj8eOBrd/3wBdro5TGQIRTtmZYAiSnut8WtjewQvsgbRN6abs J6L1Z+S/U9GjvZW+Q69CwxMaht56DNuJmEkM8ZIXwcCbXAHvsE5cG+fj7VqXkksVzL2g kPl5r+dsz3MIUcFr6AmPKxuS0AZ1+olA//czSAFPMk5VrJLrtetZafcA61lmPSBUYIg2 hGwma8lu6nDOvo5PQ7x97tKGE0K4sXBKM3VqImmSd8L4ur88j3a7jZNKF9FFOG+9IBlN 24sw== 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=9rbLAUZCHAr/HsXHohRu+PS0iZFC+ELyRZGJRmDHekI=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=dcfjaJa2xlz7Bpvqb/bIrf+5wcMGdh4DTLIu+4cXt4e/+56aFGGnAhWwINJ/C3V0sY Pwmhaj5+baS0a21oguXFUie1oxLPVH5sHHYI7APH6+k1OClYuiJtVJizKEmarHB6YRw6 8dj85NmLlHdRz5m0ta4XJIGjI7CqB9rxc89rppGVkd2sDLP5+84mn/zSnji7U4M+HX78 Y8ZPOLCjotXOjYmBDQvRcaDMqO6ZFKHROKMwPnNAkynwQU6A+RqbLcMBLnNRvRmLNub7 ee2LqhHRApVPBtlT1Kv0m5uNzQLRW46Fq5gBXq+qxMJKpB6m3sQ7H29lLlJc8Z6r6uSk Qx0w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mLGrSCmD; 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 z15-20020ac87f8f000000b004197d90f34bsi1903249qtj.400.2023.10.13.15.40.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 15:40:48 -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=mLGrSCmD; 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 82AA73858CDB for ; Fri, 13 Oct 2023 22:40:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82AA73858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697236848; bh=9rbLAUZCHAr/HsXHohRu+PS0iZFC+ELyRZGJRmDHekI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mLGrSCmDvCTvX069DBWfYMMZjCst2IXJFCjn7MTIxUIFbSOwkW0dmSNFsLh8ywMtN z/Wpas17wpy3c4DAA+1E10DBw3FYfvwErU7FimzImN3kQWm/ID9JlWVy7jBHv0uHxV VqJF3VnWUvPFqPNXUyMOX7huedMRJA2TRX9m4kWY= 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 A87B93858C2B; Fri, 13 Oct 2023 22:40:03 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A87B93858C2B 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=1697236805; cv=none; b=ZyOW4xYMaFB2v5k7/54xgLJHT1uRZu3ZLhK78XE+cJ5c9m584SfqEKGTAVlQcjZy+cWj2GfuZyEEQm0SVd7Es3OpysSm50Rr4ae0UwfFt3KaMoMOIScAIZSKCWMHqmF9tyqFyYSGIPYSa3h6IagkrtQsEQlMSY8O0mxMJ/3dGgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697236805; c=relaxed/simple; bh=dRSP1w6Wimj7RyVMSrM+jwd9rXqAKqjzX1d7deMi/Ho=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=LqwPArB6BTt6kcHO79dgjDMxRdvBrj3MWaYb2XiP79wHaCb0G9ItHnlNHW96YTGvo2gAakPgqygAO1zlEC5lL4+K14DmBQqbkb6MQzdhKnmz6XrKXJFgz0IF7nW3j6rsf78vQzB/QMy+d2qmEF5Iy5rrox6jCkaey9AJVpeHs6o= ARC-Authentication-Results: i=1; server2.sourceware.org DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A87B93858C2B 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 (m0247478.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39DMdtfe011469; Fri, 13 Oct 2023 22:40:03 GMT Received: from mxout26.s.uw.edu (mxout26.s.uw.edu [140.142.234.176]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3tqdeu8t62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 22:40:02 +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 39DMdxr0007140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Oct 2023 15:39:59 -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 39DMdx1D016619 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 15:39:59 -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 v19 00/40] Optimize type traits performance Date: Fri, 13 Oct 2023 15:37:14 -0700 Message-ID: <20231013223957.1634024-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231013211206.1215663-1-kmatsui@gcc.gnu.org> References: <20231013211206.1215663-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: smd2NxGMyDQ68A8s5DQz0_mG3RpyVEJK X-Proofpoint-ORIG-GUID: smd2NxGMyDQ68A8s5DQz0_mG3RpyVEJK 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 mlxscore=0 adultscore=0 mlxlogscore=775 bulkscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310130197 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP 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: 1776994811424638974 X-GMAIL-MSGID: 1779681826257872367 This patch series optimizes type traits performance by implementing built-in type traits and using them in libstdc++. Changes in v19: * Fixed a typo. * Rebased on top of trunk. * Improved clarity of the commit message. Changes in v18: * Removed all RID values for built-in traits and used cik_trait instead. * Improved to handle the use of non-function-like built-in trait identifiers. * Reverted all changes to conflicted identifiers with new built-ins in the existing code base. Changes in v17: * Rebased on top of trunk. * Improved clarity of the commit message. * Simplified Make-lang.in. * Made ridpointers for RID_TRAIT_EXPR and RID_TRAIT_TYPE empty. Changes in v16: * Rebased on top of trunk. * Improved clarity of the commit message. * Simplified Make-lang.in and gperf struct. * Supply -k option to gperf to support older versions than 2.8. Changes in v15: * Rebased on top of trunk. * Use gperf to look up traits instead of enum rid. Changes in v14: * Added padding calculation to the commit message. Changes in v13: * Fixed ambiguous commit message and comment. Changes in v12: * Evaluated all paddings affected by the enum rid change. Changes in v11: * Merged all patches into one patch series. * Rebased on top of trunk. * Unified commit message style. * Used _GLIBCXX_USE_BUILTIN_TRAIT. Ken Matsui (40): c++: Sort built-in traits alphabetically c-family, c++: Look up built-in traits through gperf c++: Accept the use of built-in trait identifiers c++: Implement __is_const built-in trait libstdc++: Optimize is_const trait performance c++: Implement __is_volatile built-in trait libstdc++: Optimize is_volatile trait performance c++: Implement __is_array built-in trait libstdc++: Optimize is_array trait performance c++: Implement __is_unbounded_array built-in trait libstdc++: Optimize is_unbounded_array trait performance c++: Implement __is_bounded_array built-in trait libstdc++: Optimize is_bounded_array trait performance c++: Implement __is_scoped_enum built-in trait libstdc++: Optimize is_scoped_enum trait performance c++: Implement __is_member_pointer built-in trait libstdc++: Optimize is_member_pointer trait performance c++: Implement __is_member_function_pointer built-in trait libstdc++: Optimize is_member_function_pointer trait performance c++: Implement __is_member_object_pointer built-in trait libstdc++: Optimize is_member_object_pointer trait performance c++: Implement __is_reference built-in trait libstdc++: Optimize is_reference trait performance c++: Implement __is_function built-in trait libstdc++: Optimize is_function trait performance libstdc++: Optimize is_object trait performance c++: Implement __remove_pointer built-in trait libstdc++: Optimize remove_pointer trait performance c++: Implement __is_pointer built-in trait libstdc++: Optimize is_pointer trait performance c++: Implement __is_arithmetic built-in trait libstdc++: Optimize is_arithmetic trait performance libstdc++: Optimize is_fundamental trait performance libstdc++: Optimize is_compound trait performance c++: Implement __is_unsigned built-in trait libstdc++: Optimize is_unsigned trait performance c++: Implement __is_signed built-in trait libstdc++: Optimize is_signed trait performance c++: Implement __is_scalar built-in trait libstdc++: Optimize is_scalar trait performance gcc/c-family/c-common.cc | 7 - gcc/c-family/c-common.h | 5 - gcc/cp/Make-lang.in | 26 ++ gcc/cp/constraint.cc | 112 +++++-- gcc/cp/cp-objcp-common.cc | 8 +- gcc/cp/cp-trait-head.in | 30 ++ gcc/cp/cp-trait.def | 27 +- gcc/cp/cp-trait.gperf | 91 ++++++ gcc/cp/cp-trait.h | 285 ++++++++++++++++++ gcc/cp/cp-tree.h | 14 +- gcc/cp/lex.cc | 19 ++ gcc/cp/parser.cc | 144 ++++++--- gcc/cp/semantics.cc | 157 +++++++--- gcc/testsuite/g++.dg/ext/has-builtin-1.C | 117 +++++-- gcc/testsuite/g++.dg/ext/is_arithmetic.C | 33 ++ gcc/testsuite/g++.dg/ext/is_array.C | 28 ++ gcc/testsuite/g++.dg/ext/is_bounded_array.C | 38 +++ gcc/testsuite/g++.dg/ext/is_const.C | 19 ++ gcc/testsuite/g++.dg/ext/is_function.C | 58 ++++ .../g++.dg/ext/is_member_function_pointer.C | 31 ++ .../g++.dg/ext/is_member_object_pointer.C | 30 ++ gcc/testsuite/g++.dg/ext/is_member_pointer.C | 30 ++ gcc/testsuite/g++.dg/ext/is_pointer.C | 51 ++++ gcc/testsuite/g++.dg/ext/is_reference.C | 34 +++ gcc/testsuite/g++.dg/ext/is_scalar.C | 31 ++ gcc/testsuite/g++.dg/ext/is_scoped_enum.C | 67 ++++ gcc/testsuite/g++.dg/ext/is_signed.C | 47 +++ gcc/testsuite/g++.dg/ext/is_unbounded_array.C | 37 +++ gcc/testsuite/g++.dg/ext/is_unsigned.C | 47 +++ gcc/testsuite/g++.dg/ext/is_volatile.C | 19 ++ gcc/testsuite/g++.dg/ext/remove_pointer.C | 51 ++++ libstdc++-v3/include/bits/cpp_type_traits.h | 8 + libstdc++-v3/include/std/type_traits | 284 +++++++++++++++-- 33 files changed, 1784 insertions(+), 201 deletions(-) create mode 100644 gcc/cp/cp-trait-head.in create mode 100644 gcc/cp/cp-trait.gperf create mode 100644 gcc/cp/cp-trait.h create mode 100644 gcc/testsuite/g++.dg/ext/is_arithmetic.C create mode 100644 gcc/testsuite/g++.dg/ext/is_array.C create mode 100644 gcc/testsuite/g++.dg/ext/is_bounded_array.C create mode 100644 gcc/testsuite/g++.dg/ext/is_const.C create mode 100644 gcc/testsuite/g++.dg/ext/is_function.C create mode 100644 gcc/testsuite/g++.dg/ext/is_member_function_pointer.C create mode 100644 gcc/testsuite/g++.dg/ext/is_member_object_pointer.C create mode 100644 gcc/testsuite/g++.dg/ext/is_member_pointer.C create mode 100644 gcc/testsuite/g++.dg/ext/is_pointer.C create mode 100644 gcc/testsuite/g++.dg/ext/is_reference.C create mode 100644 gcc/testsuite/g++.dg/ext/is_scalar.C create mode 100644 gcc/testsuite/g++.dg/ext/is_scoped_enum.C create mode 100644 gcc/testsuite/g++.dg/ext/is_signed.C create mode 100644 gcc/testsuite/g++.dg/ext/is_unbounded_array.C create mode 100644 gcc/testsuite/g++.dg/ext/is_unsigned.C create mode 100644 gcc/testsuite/g++.dg/ext/is_volatile.C create mode 100644 gcc/testsuite/g++.dg/ext/remove_pointer.C