From patchwork Wed Feb 28 19:26:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 21108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3570277dyb; Wed, 28 Feb 2024 11:42:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVuUvIjq8/2ew6pVXHK7ze6P06+2m+Q3XEE6r5MDSyJg0wFkgaOSSE+aaPVfnOtlAT4PNuhaFs7mEpYcWwY8sRV9MUHQQ== X-Google-Smtp-Source: AGHT+IFzKYjbr32S63cti5zfsPvkivP7Ywcr+RJsrV512UgJsOl+qnjls+cLLaFK4Wu6zBKO0dW4 X-Received: by 2002:a5b:acc:0:b0:dcd:59e4:620c with SMTP id a12-20020a5b0acc000000b00dcd59e4620cmr201148ybr.49.1709149359284; Wed, 28 Feb 2024 11:42:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709149359; cv=pass; d=google.com; s=arc-20160816; b=QR/9JQQnPyjNFns0VWJJLtCzsVgjLZXcS0JCK7k3E+h6JHj9zImi+KZhMajdVyLuvh yEdazjDo2/Wvi91wDD4rVvWJT/J6rt0FWqZRz49TBuhyb9VZqMwOMJ/XKNMs25K1l63U +2kMRjhOgHZ38PkFpFpO1GLE24kUShbvxppM0hgnk3SekOJUzjLXIJPVCpob4E/L5rWW w3UQVjaYSZGX7tiHyIAyuw6TNWOx2GaJEKANN/976mFrgY2uiEaLfrc6fjaQ4ZFJl/nk dLzk9p8kNq2vKX52/RdY0BaLBpIzxfU7j20IXpLygOsjw/rHOLyhV0NBXMNkuBX1GWxn ds/g== 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=IoN+8kOKwxHyLH/oFwJ3DMd+klJEWpNq91dVrcA9M6o=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=ugRAOd8o8kwCCH+XUkzv1J6XMvZIPSZMila6A6E4DZMApWGs14UJpF+eVpMEBV3YyM lTdHmuBXDq8X/LflVonPh98jb+rKfrOhUlkDfifbF3eOn10RfOXiXx8xkRtDA2VdmVSj RjCQh1OHp3pTxhZ2D9GvA82Pe6kbsEyLRd96udD8X94EbR/GQvanHomQ3wwSfok+3ELq 9lWis0EnHIXi6jdqPXgM/wS3VDFDOHbUEjZt7HwZ7nqWkM0izuK7vJ75ij/hOW2vsU64 93RfLFA9TYju2zO/VADH5hAQVR6kUoxBV3DoKITa1gVv5dYSrxqxW7Fx8umFKjPqu9h+ 8X3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K+hxQB4U; 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 v6-20020ac87486000000b0042c59340e59si114462qtq.598.2024.02.28.11.42.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 11:42:39 -0800 (PST) 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=K+hxQB4U; 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 D4B1B38582BE for ; Wed, 28 Feb 2024 19:42:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4B1B38582BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709149358; bh=IoN+8kOKwxHyLH/oFwJ3DMd+klJEWpNq91dVrcA9M6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=K+hxQB4UK8z3Mal4SbHOGxkzlpEQwY+oq1guFLZBcREswkFboCYW4lxkbdpa2hAIN Aq9XPS0zEl57QLM6nyga/T3GlxDtnTgPzgnpaWyVPIdCMLzrIsFXSGeByi3cIWuy4i nY/k6evW72Abcfj7xLpphqQD7yWRuXNhJg3Kiywc= 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 7BEED3858018; Wed, 28 Feb 2024 19:32:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BEED3858018 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 7BEED3858018 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=1709148747; cv=none; b=DDT35QtoeMbsYkDhgl4HykEASNwD0a75zhDq8+jDPMZFNbkASje8hjlCL9P7mD0yPmaws9W04El64H0pTVmZXnDKUaGRg7NpHm0ovacQ6yKSq5Kft2Bhoye2YfA6jD+jJ8JqZtrl5cYuvRBKXxZow32Bp7aHsa9kVaalkYWigcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709148747; c=relaxed/simple; bh=292+O3yMmmPJBibK1jVtx7pxM5YdctGZ/SCsScw9zMA=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=nlXHuzekNaZrh3Y12HPO0yqlaAUY/DOZgdJB2qLNqngAZGdWjrjsbwyAngn0zVRD6vlsHzoaE78D/vPqVHaBDrF5s0rsVQIXQoWeuDGqVY3kEoas8ip7rI16rYcrTodSOfvMH09rs0OfzhCqRwwRkd1Pv9+QJIL5E6aSsbO390s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247471.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41SJQHg4013735; Wed, 28 Feb 2024 19:32:18 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3wjamt09n9-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Feb 2024 19:32:18 +0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.234.157]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW24.02) with ESMTP id 41SJSoNY020750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Feb 2024 11:28:50 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.128]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW24.02) with ESMTPSA id 41SJSoTI015429 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Feb 2024 11:28:50 -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 v14 00/26] Optimize more type traits Date: Wed, 28 Feb 2024 11:26:05 -0800 Message-ID: <20240228192843.188979-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240221093616.4001742-1-kmatsui@gcc.gnu.org> References: <20240221093616.4001742-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: a2ennN4PH89he8rGN4-T7eAzPii9QhFz X-Proofpoint-ORIG-GUID: a2ennN4PH89he8rGN4-T7eAzPii9QhFz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-28_08,2024-02-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 malwarescore=0 bulkscore=0 spamscore=0 clxscore=1034 phishscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=755 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402280154 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, 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: 1792172998439397181 X-GMAIL-MSGID: 1792172998439397181 Hi, This patch series implements __is_const, __is_volatile, __is_pointer, and __is_unbounded_array built-in traits, which were isolated from my previous patch series "Optimize type traits compilation performance" because they contained performance regression.  I confirmed that this patch series does not cause any performance regression.  The main reason of the performance regression were the exhaustiveness of the benchmarks and the instability of the benchmark results.  Also, this patch series includes built-ins for add_pointer, remove_extent, remove_all_extents, add_lvalue_reference, add_rvalue_reference, decay, rank, is_invocable, and is_nothrow_invocable.  Here are the benchmark results: is_const: https://github.com/ken-matsui/gcc-bench/blob/main/is_const.md#sat-dec-23-090605-am-pst-2023 time: -4.36603%, peak memory: -0.300891%, total memory: -0.247934% is_const_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_const_v.md#sat-jun-24-044815-am-pdt-2023 time: -2.86467%, peak memory: -1.0654%, total memory: -1.62369% is_volatile: https://github.com/ken-matsui/gcc-bench/blob/main/is_volatile.md#sun-oct-22-091644-pm-pdt-2023 time: -5.25164%, peak memory: -0.337971%, total memory: -0.247934% is_volatile_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_volatile_v.md#sat-dec-23-091518-am-pst-2023 time: -4.06816%, peak memory: -0.609298%, total memory: -0.659134% is_pointer: https://github.com/ken-matsui/gcc-bench/blob/main/is_pointer.md#sat-dec-23-124903-pm-pst-2023 time: -2.47124%, peak memory: -2.98207%, total memory: -4.0811% is_pointer_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_pointer_v.md#sun-oct-22-122257-am-pdt-2023 time: -4.71336%, peak memory: -2.25026%, total memory: -3.125% is_unbounded_array: https://github.com/ken-matsui/gcc-bench/blob/main/is_unbounded_array.md#sun-oct-22-091644-pm-pdt-2023 time: -6.33287%, peak memory: -0.602494%, total memory: -1.56035% is_unbounded_array_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_unbounded_array_v.md#sat-dec-23-010046-pm-pst-2023 time: -1.50025%, peak memory: -1.07386%, total memory: -2.32394% add_pointer_t: https://github.com/ken-matsui/gcc-bench/blob/main/add_pointer_t.md#wed-feb-28-060044-am-pst-2024 time: -21.6673%, peak memory: -14.6666%, total memory: -17.4716% remove_extent_t: https://github.com/ken-matsui/gcc-bench/blob/main/remove_extent_t.md#wed-feb-28-063021-am-pst-2024 time: -14.4089%, peak memory: -2.71836%, total memory: -9.87013% remove_all_extents_t: https://github.com/ken-matsui/gcc-bench/blob/main/remove_all_extents_t.md#wed-feb-28-064716-am-pst-2024 time: -28.8941%, peak memory: -16.6981%, total memory: -23.6088% add_lvalue_reference_t: https://github.com/ken-matsui/gcc-bench/blob/main/add_lvalue_reference_t.md#wed-feb-28-070023-am-pst-2024 time: -33.8827%, peak memory: -24.9292%, total memory: -25.3043% add_rvalue_reference_t: https://github.com/ken-matsui/gcc-bench/blob/main/add_rvalue_reference_t.md#wed-feb-28-070701-am-pst-2024 time: -23.9186%, peak memory: -17.1311%, total memory: -19.5891% decay_t: https://github.com/ken-matsui/gcc-bench/blob/main/decay_t.md#wed-feb-28-072330-am-pst-2024 time: -42.4076%, peak memory: -29.2077%, total memory: -33.0914% rank: https://github.com/ken-matsui/gcc-bench/blob/main/rank.md#wed-feb-28-074917-am-pst-2024 time: -33.7312%, peak memory: -27.5885%, total memory: -34.5736% rank_v: https://github.com/ken-matsui/gcc-bench/blob/main/rank_v.md#wed-feb-28-073632-am-pst-2024 time: -40.7174%, peak memory: -16.4653%, total memory: -23.0131% is_invocable_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_invocable.md#wed-feb-28-111001-am-pst-2024 time: -58.8307%, peak memory: -59.4966%, total memory: -59.8871% (This benchmark is not exhaustive as my laptop crashed with larger benchmarks) is_nothrow_invocable_v: https://github.com/ken-matsui/gcc-bench/blob/main/is_nothrow_invocable.md#wed-feb-28-112414-am-pst-2024 time: -70.4102%, peak memory: -62.5516%, total memory: -65.5853% (This benchmark is not exhaustive as my laptop crashed with larger benchmarks) Sincerely, Ken Matsui Ken Matsui (26): 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_pointer built-in trait libstdc++: Optimize std::is_pointer compilation performance c++: Implement __is_unbounded_array built-in trait libstdc++: Optimize std::is_unbounded_array compilation performance c++: Implement __add_pointer built-in trait libstdc++: Optimize std::add_pointer compilation performance c++: Implement __remove_extent built-in trait libstdc++: Optimize std::remove_extent compilation performance c++: Implement __remove_all_extents built-in trait libstdc++: Optimize std::remove_all_extents compilation performance c++: Implement __add_lvalue_reference built-in trait libstdc++: Optimize std::add_lvalue_reference compilation performance c++: Implement __add_rvalue_reference built-in trait libstdc++: Optimize std::add_rvalue_reference compilation performance c++: Implement __decay built-in trait libstdc++: Optimize std::decay compilation performance c++: Implement __rank built-in trait libstdc++: Optimize std::rank compilation performance c++: Implement __is_invocable built-in trait libstdc++: Optimize std::is_invocable compilation performance c++: Implement __is_nothrow_invocable built-in trait libstdc++: Optimize std::is_nothrow_invocable compilation performance gcc/cp/constraint.cc | 27 ++ gcc/cp/cp-trait.def | 13 + gcc/cp/cp-tree.h | 2 + gcc/cp/method.cc | 132 +++++++ gcc/cp/semantics.cc | 92 ++++- .../g++.dg/ext/add_lvalue_reference.C | 21 ++ gcc/testsuite/g++.dg/ext/add_pointer.C | 39 ++ .../g++.dg/ext/add_rvalue_reference.C | 20 + gcc/testsuite/g++.dg/ext/decay.C | 22 ++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 39 ++ gcc/testsuite/g++.dg/ext/is_const.C | 20 + gcc/testsuite/g++.dg/ext/is_invocable1.C | 349 ++++++++++++++++++ gcc/testsuite/g++.dg/ext/is_invocable2.C | 139 +++++++ gcc/testsuite/g++.dg/ext/is_invocable3.C | 51 +++ gcc/testsuite/g++.dg/ext/is_invocable4.C | 33 ++ .../g++.dg/ext/is_nothrow_invocable.C | 62 ++++ gcc/testsuite/g++.dg/ext/is_pointer.C | 51 +++ gcc/testsuite/g++.dg/ext/is_unbounded_array.C | 37 ++ gcc/testsuite/g++.dg/ext/is_volatile.C | 20 + gcc/testsuite/g++.dg/ext/rank.C | 24 ++ gcc/testsuite/g++.dg/ext/remove_all_extents.C | 16 + gcc/testsuite/g++.dg/ext/remove_extent.C | 16 + libstdc++-v3/include/bits/cpp_type_traits.h | 31 +- libstdc++-v3/include/std/type_traits | 142 ++++++- .../is_invocable/incomplete_args_neg.cc | 1 + .../20_util/is_invocable/incomplete_neg.cc | 1 + .../incomplete_args_neg.cc | 1 + .../is_nothrow_invocable/incomplete_neg.cc | 1 + 28 files changed, 1389 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/add_lvalue_reference.C create mode 100644 gcc/testsuite/g++.dg/ext/add_pointer.C create mode 100644 gcc/testsuite/g++.dg/ext/add_rvalue_reference.C create mode 100644 gcc/testsuite/g++.dg/ext/decay.C create mode 100644 gcc/testsuite/g++.dg/ext/is_const.C create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable1.C create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable2.C create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable3.C create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable4.C create mode 100644 gcc/testsuite/g++.dg/ext/is_nothrow_invocable.C create mode 100644 gcc/testsuite/g++.dg/ext/is_pointer.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/rank.C create mode 100644 gcc/testsuite/g++.dg/ext/remove_all_extents.C create mode 100644 gcc/testsuite/g++.dg/ext/remove_extent.C