From patchwork Sat Jan 6 05:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 18782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6618647dyb; Fri, 5 Jan 2024 21:09:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2jnKHtvEifMXW90ZbRvElAS3YvluoZRgfMDTEHkKqF09Qqr9QYMgqnwRjA2JbuqUrIlNo X-Received: by 2002:a05:622a:1315:b0:429:8361:8da6 with SMTP id v21-20020a05622a131500b0042983618da6mr280999qtk.43.1704517761059; Fri, 05 Jan 2024 21:09:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704517761; cv=pass; d=google.com; s=arc-20160816; b=VNb7YNMyUQeWBh1tXFsN+DooMUROMhpgOyowGlbbHiWe/0yI1KiutrrwK8moQTxOCr 2TLX58O4479D+v1lv+4SD+fMgrFiPbh1xcBSi3KLLKD+4P+n4bVQxg8Zvu8PZ7/l/gd1 G5+WmyGOQYgTPfiNPT7uyZOqTw3iqXKFX8mQvAvQn5DV/mR4/fYSN1t48V/W6qKEmA9E XU4N9MXlMzcgzQ7JRigY7Daq/hXBb2DSg7aZ8ymgKAfmtu645IFYiIiOg1vkP71iG5gO jK9RU4PhZCPUkingQcDq/ulpT+dLpQAiEavG/wnAFnDy3TwVmaNxg4T+4r+crgvRfFes 6XBQ== 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=tVHwQQMIqCGSbRdtxxFVP3wkiRnk/ZiKYBRn0h4sEXE=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=SH+bAN1KsHXRqa6Wia5lrTaakJ79xJfLgUY/xNQXFfCsiNimVGVwt1im98lnzUotN4 F60bxLglF/wck/rOrvS7aWO0HplJtZt5YQzTCti9ifZm7Kp3ADDYH5eIXad5q3r45Jat yFs8AczpKOG5F3wKpwjOy+m6Ur48Db2RlRhAYPvQRzjY5lnCaIOmfLYMlcHDXspugoe1 uWHjDvTn7lr1Ff98TnLYu6gcu8zH6V+Bpew0KxH17lyDpXOtkc9dlPqjPn1YUey3qCwo VEYNSmwTFPeJ2tYy0drGQSC9TDhlW+HDaavru8ECZcLSXAyiWWJDdzCoaq5OQsijMcZR CRRw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qMpgbzMn; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e17-20020ac85dd1000000b0042979e0abd6si2439264qtx.724.2024.01.05.21.09.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 21:09:21 -0800 (PST) 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=qMpgbzMn; 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 B1869384F020 for ; Sat, 6 Jan 2024 05:09:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1869384F020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704517760; bh=tVHwQQMIqCGSbRdtxxFVP3wkiRnk/ZiKYBRn0h4sEXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qMpgbzMnpjloezvvG6woJ2Gg34dySw+ZoS/64RRk/tEQA6L7sCAenFlru4xcqnrtV F7bCDEXWMH0KVue3YylG5CKPaacEJx0hIMpqL4/Yox7/UeSNr3Y+gtZr4jerw84/Mv 8/37EfV8jgsImOztCuHEHZwnjMVxFIKUmUfsq/BQ= 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 230763858C60; Sat, 6 Jan 2024 05:08:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 230763858C60 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 230763858C60 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=1704517685; cv=none; b=cRGGYRlziS6i0XUGf45Ivx0ZiUmiNWfKnlR57Bt2s5dAnf1KZ3MeocrwTbS947HaY4a5Nz6nAInjPXltjK13z/BRQPPdNLZ5yUkp0XiqfCuZx0Ggj9DEHzwUp1Akv9jpG8vqSnWP/HyY8shomFHsISTLA3Dwn9MbAo0yfqWig6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704517685; c=relaxed/simple; bh=IsoBHT5r1IL0SaAJD8MzTV7Wn/3aNvuculYmI80mXE0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cXsd7XpcrHZ7iiHztEXN+fVzClS8bMrlfX9vX+u1tXNYeXW8r644pArww9ICMEJx4rpiUAySPMqLAVYOyjm0rWUoASOJCA4tfbyv9wVwiyfDgHJaVhQk6V2Phm2vPvf1LGPQlviTQ4eA6wK40lxowat9VOeUkaAV8vvAO2AEms4= 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 40655xgl005706; Sat, 6 Jan 2024 05:08:02 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3vexq30ax2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jan 2024 05:08:02 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout22.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 406580Oh007430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 21:08:00 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.143]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 406580H5000483 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2024 21:08:00 -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 v3 0/8] Optimize more type traits Date: Fri, 5 Jan 2024 21:05:34 -0800 Message-ID: <20240106050754.3054782-1-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: LS0yh4JcbHSVAba_HVSJ1QGk9LORYCrm X-Proofpoint-GUID: LS0yh4JcbHSVAba_HVSJ1QGk9LORYCrm 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=2024-01-05_08,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1034 impostorscore=0 bulkscore=0 spamscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 mlxlogscore=240 adultscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401060033 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786110183244563676 X-GMAIL-MSGID: 1787316415997376290 Changes in v3: - Rebased on top of master. - Fixed __is_pointer in cpp_type_traits.h. Changes in v2: - Removed testsuite_tr1.h includes from the testcases. --- 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% 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 | 31 +++++++- libstdc++-v3/include/std/type_traits | 73 +++++++++++++++++-- 10 files changed, 267 insertions(+), 9 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