From patchwork Tue Oct 10 09:46: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: 15147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp77409vqb; Tue, 10 Oct 2023 02:54:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQSgdeoxedIXryOXHzYMZBqTr2wAwTqLau/cs0Qgb6bPEHQN0d6Z96Q56MgJgvTKAevl8t X-Received: by 2002:a17:906:bcf0:b0:9a6:1446:852c with SMTP id op16-20020a170906bcf000b009a61446852cmr16583671ejb.27.1696931676676; Tue, 10 Oct 2023 02:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696931676; cv=none; d=google.com; s=arc-20160816; b=hYZu32FZlHpsR0kB6ghvdwkXyk5XJidFvRKlLekZGT+mdj3M8lIfQ4J1HoYt9VMc/F sPneLhUkVp/stLZDVGBPVLFWG3RbFrcy0BsJXbPZYQO4hCju7PCwwuKRAkww11rxuZLR YHR8imK/krIINRPIcOANA6Vxi5m5NK+WnMe7BO+Bppj28bmRVTDaJ9Br7i4aR6EwtXxZ zJRSSfQyyRE2LWu15kUd3Zq818OaTJ6YwyhSl1QNGzP2fAWj1OwcWVYj9WTFvi0hvjMf HC/g+YCj1BVfp+JYAhiJINdZFwTKhxPyt6muhTByVDxJcuPnf/tdivxnn+Cje6HT1EOV Z1Lg== ARC-Message-Signature: i=1; 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:delivered-to:dkim-signature:dkim-filter; bh=4SpWPfo5jU8JhxKtvRWLtusmxQVTybi3cax+LKuazNk=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=eePG3PtFCCmNflrNLL4284d92utDweU00c1u+6f9AP+QVQmE2I/pelWzHA2qsmEwwX UBL3pClfbbWwo4/VR77In7vdJt0YNcBhvbzBPVV6fVrrQ+Jgs+Uny0FFCrsEp1On82ms vxpMhEECJ1HaLHkdxpbvMd+rT5eQO3prfu6CNIriFHSESvs4UxAY57MN7BBFkkhNa1Hn XPBdhDTDhFoIKLlPHmp+vIqBtxUFJVmO4qCFgKnooA5Mec0ycQZRTc6ccP+39F4XJ7it a5BfbflHUvnpdcNnULt+tOGbUfoCGl1Z0GztWcw5fiCDs5utFEZDujno5upeNNETQruL 6AjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VRoYuf2w; 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 p15-20020a170906b20f00b0099cb1ff44bcsi5440081ejz.613.2023.10.10.02.54.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 02:54:36 -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=VRoYuf2w; 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 ED7143857030 for ; Tue, 10 Oct 2023 09:53:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED7143857030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696931640; bh=4SpWPfo5jU8JhxKtvRWLtusmxQVTybi3cax+LKuazNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VRoYuf2wswsfOW00kxUdjvJqnS0u8GZNHjpkj9woL1ZF8rmurBgzofcPCWvifzEYG Cj4dc4cuHvF8TNyY5ewrLGqomHHvyRoH9Ubf7EV3jPI2b9wo5RlVQCNoufZDrXVHX2 Z4gF5ExYTWeU3wUBuDkSDdsHJ7wI/QnwE3tzE5Zc= 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 F23113858D32; Tue, 10 Oct 2023 09:53:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F23113858D32 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 (m0247473.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39A9oS6J024443; Tue, 10 Oct 2023 09:53:10 GMT Received: from mxout26.s.uw.edu (mxout26.s.uw.edu [140.142.234.176]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3tmu6qj24f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Oct 2023 09:53:10 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.132]) by mxout26.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 39A9qi1w029420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Oct 2023 02:52:44 -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 39A9qhT6014491 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Oct 2023 02:52:44 -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 v15 00/39] Optimize type traits performance Date: Tue, 10 Oct 2023 02:46:14 -0700 Message-ID: <20231010095229.3364786-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230915023640.75216-1-kmatsui@gcc.gnu.org> References: <20230915023640.75216-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 1Wf-pBMLx_pomOpd-3xq91zc8FvGGq1B X-Proofpoint-GUID: 1Wf-pBMLx_pomOpd-3xq91zc8FvGGq1B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-10_05,2023-10-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 spamscore=0 clxscore=1034 phishscore=0 suspectscore=0 mlxlogscore=718 impostorscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310100074 X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, 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: 1779361829566680846 This patch series optimizes type traits performance by implementing built-in type traits and using them in libstdc++. 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 (39): c++: Sort built-in identifiers alphabetically c-family, c++: Look up traits through gperf instead of enum rid. 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++, libstdc++: Implement __is_pointer built-in trait libstdc++: Optimize is_pointer trait performance c++, libstdc++: 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++, libstdc++: Implement __is_signed built-in trait libstdc++: Optimize is_signed trait performance c++, libstdc++: Implement __is_scalar built-in trait libstdc++: Optimize is_scalar trait performance gcc/c-family/c-common.cc | 12 +- gcc/c-family/c-common.h | 7 +- gcc/cp/Make-lang.in | 26 ++ gcc/cp/constraint.cc | 112 +++++-- gcc/cp/cp-objcp-common.cc | 6 +- gcc/cp/cp-trait-head.in | 31 ++ gcc/cp/cp-trait.def | 27 +- gcc/cp/cp-trait.gperf | 92 ++++++ gcc/cp/cp-trait.h | 287 ++++++++++++++++++ gcc/cp/parser.cc | 72 ++--- 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 ++++ gcc/testsuite/g++.dg/tm/pr46567.C | 48 +-- gcc/testsuite/g++.dg/torture/20070621-1.C | 4 +- gcc/testsuite/g++.dg/torture/pr57107.C | 8 +- libstdc++-v3/include/bits/charconv.h | 2 +- libstdc++-v3/include/bits/cpp_type_traits.h | 18 +- libstdc++-v3/include/bits/deque.tcc | 6 +- libstdc++-v3/include/bits/locale_facets.tcc | 6 +- libstdc++-v3/include/bits/stl_algobase.h | 14 +- libstdc++-v3/include/bits/uniform_int_dist.h | 4 +- libstdc++-v3/include/bits/valarray_array.h | 2 +- libstdc++-v3/include/c_global/cmath | 48 +-- libstdc++-v3/include/c_std/cmath | 24 +- libstdc++-v3/include/ext/numeric_traits.h | 18 +- libstdc++-v3/include/std/type_traits | 284 +++++++++++++++-- libstdc++-v3/include/tr1/cmath | 24 +- 44 files changed, 1807 insertions(+), 300 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