From patchwork Sat Dec 23 22:02:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 1879919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Ys8+Jn9i; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SyJBF0b06z1ydZ for ; Sun, 24 Dec 2023 09:05:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 957C73857C49 for ; Sat, 23 Dec 2023 22:05:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 957C73857C49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369106; bh=/OlZUgz9Jut6v6PoQy33BlZMHerI5isKSyiBnQ+2JUY=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Ys8+Jn9iJseKtB1tf4/TnpYfkK+Cj5xKW59awPakL/Uh03H/mBLEvGL+K19aCe9ry hwpRyVxK6dqo0zYqZZnnlnXVQSj8kgAA5Ygnzir7vhKd1wh8F7e57o6gCNg1juIbuU 0EJOwhdOW04UCEPk4cwBcYkcN7thZJt3F0O39MPg= 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 EECE53858C54; Sat, 23 Dec 2023 22:04:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EECE53858C54 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 EECE53858C54 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=1703369088; cv=none; b=HjGUMhyrLsqzCBpsc0zfJgnfmJauzGD+zeaYUXBCL/BAWbXwGLEeoUCU6DXGpr1DWU+/v5V6ABtiLxbGi3YD6+ykV8zf5cW7RXnis2TibyZDho3wlzbuNrXmSPu5JocXAGczyvQBh2mIpuRJB7EqLZ+5q7diXCknDxbM6QoATaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369088; c=relaxed/simple; bh=HfR1++nzv+s1TNjSYg5k3D44eJWrMFDSc3Lnk/NsyOI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=sHYLFFUMeXvCahsMljm6r3kVvINp3AW7ZpWXDTZg8UIh400PsKpdmhr6IYC909C8hnFU9kkkhpcgBuZ0nFgSkdKY96R9rqgTTtIpu/MXk/jx0Uts3Tb97CacBDZFetynDju+QkQfCRImof4+6AACRps+e4l1xVjOUy4elfESFag= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247476.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM1HlT013824; Sat, 23 Dec 2023 22:04:45 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5r01k6sn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:04:45 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM4YTR013768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:04:34 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y23011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:04:34 -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 v2 0/8] Optimize more type traits Date: Sat, 23 Dec 2023 14:02:41 -0800 Message-ID: <20231223220432.712093-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Proofpoint-GUID: nql5LBTSdwAPD4Qd6q7mnMZHrzrpv80J X-Proofpoint-ORIG-GUID: nql5LBTSdwAPD4Qd6q7mnMZHrzrpv80J 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=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=289 adultscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 clxscore=1034 lowpriorityscore=0 phishscore=0 spamscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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. Here are new 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_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_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% Changes in v2: - Removed testsuite_tr1.h includes from the testcases. Ken Matsui (8): 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 gcc/cp/constraint.cc | 12 +++ gcc/cp/cp-trait.def | 4 + gcc/cp/semantics.cc | 16 ++++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 12 +++ gcc/testsuite/g++.dg/ext/is_const.C | 20 +++++ 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 +++++ libstdc++-v3/include/bits/cpp_type_traits.h | 29 ++++++++ libstdc++-v3/include/std/type_traits | 73 +++++++++++++++++-- 10 files changed, 266 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_const.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