From patchwork Tue Oct 17 11:27:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 15485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4067283vqb; Tue, 17 Oct 2023 04:33:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYZuWjwMBf6tP5wybtK1oEdZmaj5ZKf5zegIUVhHdj5AsfT8uo0YlGdMqaE66Ht60zM/O4 X-Received: by 2002:ac8:5f95:0:b0:40a:fc6a:e87b with SMTP id j21-20020ac85f95000000b0040afc6ae87bmr2257044qta.22.1697542427083; Tue, 17 Oct 2023 04:33:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697542427; cv=pass; d=google.com; s=arc-20160816; b=k+yJ7Pglw+lntihtrXE1J33IJkmHkFUAzE360XWFeyKps0JM9wSPsZyhzEmkJ/BiYb 6DpY7H/jG3OpinIlHQsOmTOJx+g+esF4Mzp4i7qEdhzGbzJwMSm+Wd6CCzcfLuDX57Od dGaqWtu8ci8LpljlkvxqzUUvVydMZOeY751Pg08TYBdNfTDDueZhkQG+7TuRkh0rlztY ScYtoZ/ROCdftrQeha+IqKMTvjOusKyXzJrvD21rQeR9H4o3y7JJ0rufLb1SJrAlAocZ zYJt8TAZpUavzZiXr6oyr5zknIjtdN5Ol5u+Y0qFv+kR9nRtcjsuLrh+lBjB9ZasF0pl qXsA== 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:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=Sd20rmWq0/JVnnUqYR5+3o3qdEN0480nf6vnkP4h3DM=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=XSREuOsQa5xGGwC5QNyU97x/8PV/mSG+y8U4/cDA7uOhaG+pFFu1FeeHk6ju+WrJx0 yGrjY3d0pI2du3s4RtXWDXmC0LIuVI39O6LTFw91mBeex/8+hDsDTMSvrY0VNBTSfJ4D U07kTkzH+zmET4Jo5IBBwGNxfH2SYwPpEPCvvlSGY8Mg+AYUp4Ek2o5Z3UmlRCEiax5l uNxc5DmUMGf0dvDfXq7ewX593E6Cw+q9YJDWIZ2SueBBAiCuXQK5t29JDr+0hFvlTiWk w85ew+a7mxelA0LRadbaG5eCe6pjO00IBf+LTL8zTBqj1Wwru/cfWT26SCP2tpq/dZEJ nYoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CqcEZUvD; 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 e19-20020a05622a111300b0041985083e84si955326qty.105.2023.10.17.04.33.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 04:33:47 -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=CqcEZUvD; 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 CD2D23858004 for ; Tue, 17 Oct 2023 11:33:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD2D23858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697542426; bh=Sd20rmWq0/JVnnUqYR5+3o3qdEN0480nf6vnkP4h3DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CqcEZUvDhu219ZVcKNjv/5nM01YJiDynwAhvVw8TKOVMfIFwBgXUcaDdRFWXSPHPf e6Pdg4Nqns3zAD8UoE7m/kW9PXDbO17jU3yqA9C8ScBPjUEJ9F8QW2KvYEH7a6VMjx XTbCen3TOPp5w+7NKfREW/n/ARLYxeu9Ivfy8YRs= 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 BAE293858D33; Tue, 17 Oct 2023 11:33:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BAE293858D33 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 BAE293858D33 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=1697542384; cv=none; b=Fs/+kARhgo7zwBvE631mik73V0PY+xsM3mdKHeYR9Eue3yBKhnJ9basEowHpFv4coBym2x7H/Lod3tf4AD4M67gnjtpU41bN1O9Zhqb4A3Kn+J4jOo/L9PElz+PrlBKTEZTFatVYYNSQaZr/PJPrODZ7XxHnMFALEVPE8jtUCYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697542384; c=relaxed/simple; bh=TDaM3iLjfZbEqfj7Vxp4vX80fHUP7pRokAsnDRVbXtU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=WdiH7/podmhvQm/ayssLFqn4jjPjr3+Y1qfpk4B6xjWANfqKuJt6VKfB+fKjSJmbHaGgX88ITT9R5CuuPuwVzPwAE/hVB4pDKa50XjLRuBvPN/izBBPHsaPUKzDi+PiI9jq60vAGj3/nv2cNX1dwC7qETm0pKYIs7nPXeaHycMs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247479.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39HBK2BS026445; Tue, 17 Oct 2023 11:33:01 GMT Received: from mxout23.cac.washington.edu (mxout23.cac.washington.edu [140.142.32.140]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3tsf40afh3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 11:33:00 +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 39HBWj61004283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Oct 2023 04:32:45 -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 39HBWiMD001840 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 04:32:45 -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 v21 00/30] Optimize type traits performance Date: Tue, 17 Oct 2023 04:27:31 -0700 Message-ID: <20231017113242.664523-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231016001227.2717180-1-kmatsui@gcc.gnu.org> References: <20231016001227.2717180-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: YSS2OPzXgJoMk1wWiH7vPAWvpaSPTWtq X-Proofpoint-ORIG-GUID: YSS2OPzXgJoMk1wWiH7vPAWvpaSPTWtq 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-16_13,2023-10-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=560 malwarescore=0 bulkscore=0 clxscore=1034 adultscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310170096 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: 1780002247605624699 This patch series optimizes type traits performance by implementing built-in type traits and using them in libstdc++. Changes in v21: * Used _GLIBCXX_USE_BUILTIN_TRAIT instead of __has_builtin in cpp_type_traits.h. * Added const char* name to struct cp_trait, and loop over cp_traits in init_cp_traits to get the name. * Isolated patches for integral-related built-in traits from this patch series since they are not ready for review yet. * Implemented __is_object built-in trait. Changes in v20: * Used identifier node instead of gperf to look up built-in traits. 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 (30): c-family, c++: Look up built-in traits via identifier node c++: Accept the use of built-in trait identifiers c++: Implement __is_const built-in trait libstdc++: Optimize std::is_const compilation performance c++: Implement __is_volatile built-in trait libstdc++: Optimize std::is_volatile compilation performance c++: Implement __is_array built-in trait libstdc++: Optimize std::is_array compilation performance c++: Implement __is_unbounded_array built-in trait libstdc++: Optimize std::is_unbounded_array compilation performance c++: Implement __is_bounded_array built-in trait libstdc++: Optimize std::is_bounded_array compilation performance c++: Implement __is_scoped_enum built-in trait libstdc++: Optimize std::is_scoped_enum compilation performance c++: Implement __is_member_pointer built-in trait libstdc++: Optimize std::is_member_pointer compilation performance c++: Implement __is_member_function_pointer built-in trait libstdc++: Optimize std::is_member_function_pointer compilation performance c++: Implement __is_member_object_pointer built-in trait libstdc++: Optimize std::is_member_object_pointer compilation performance c++: Implement __is_reference built-in trait libstdc++: Optimize std::is_reference compilation performance c++: Implement __is_function built-in trait libstdc++: Optimize std::is_function compilation performance c++: Implement __is_object built-in trait libstdc++: Optimize std::is_object compilation performance c++: Implement __remove_pointer built-in trait libstdc++: Optimize std::remove_pointer compilation performance c++: Implement __is_pointer built-in trait libstdc++: Optimize std::is_pointer compilation performance gcc/c-family/c-common.cc | 7 - gcc/c-family/c-common.h | 5 - gcc/cp/constraint.cc | 39 ++++ gcc/cp/cp-objcp-common.cc | 8 +- gcc/cp/cp-trait.def | 14 ++ gcc/cp/cp-tree.h | 33 ++- gcc/cp/lex.cc | 21 ++ gcc/cp/parser.cc | 133 +++++++---- gcc/cp/semantics.cc | 59 +++++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 42 ++++ 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_object.C | 29 +++ gcc/testsuite/g++.dg/ext/is_pointer.C | 51 +++++ gcc/testsuite/g++.dg/ext/is_reference.C | 34 +++ gcc/testsuite/g++.dg/ext/is_scoped_enum.C | 67 ++++++ gcc/testsuite/g++.dg/ext/is_unbounded_array.C | 37 ++++ 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 | 207 +++++++++++++++++- 26 files changed, 1021 insertions(+), 77 deletions(-) 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_object.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_scoped_enum.C create mode 100644 gcc/testsuite/g++.dg/ext/is_unbounded_array.C create mode 100644 gcc/testsuite/g++.dg/ext/is_volatile.C create mode 100644 gcc/testsuite/g++.dg/ext/remove_pointer.C