From patchwork Tue Aug 27 09:55:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1977220 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=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=qHth3AFI; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=qHth3AFI; 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 4WtNGP2n1Rz1yg0 for ; Tue, 27 Aug 2024 19:55:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28C07385E45F for ; Tue, 27 Aug 2024 09:55:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:260e::600]) by sourceware.org (Postfix) with ESMTPS id EE718385DDD2 for ; Tue, 27 Aug 2024 09:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE718385DDD2 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EE718385DDD2 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:260e::600 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1724752531; cv=pass; b=Wa4RTyOIe+E3+xTN7FMGuA/SxkBCAG7bYR6bn2bgtIaGSONyasksdqBJlIt+1DTURbE/L/xqPyrOR6aCHjar3alVT3RFIuc8biQPIYwck3G9x9BgcIVl8vPIJDEDcKkjcE4VuEBxoAR66rGBKEbgHdS+kNPdwcCwuLWM1p8Yi5o= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1724752531; c=relaxed/simple; bh=MqB5TRkOZTRGuKcXS7iWXRNWdlawGJT/GFW9DuFzAKA=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=oYrtKaxvvvc5h6v7DqhP4xACxBL2im56deV6qFSKB1jxqEcI1vgDFot3YdmKFBFbvXVZoDKWAzWnZpxHp99BXXAxtHsw2MPG+t12tV/6APFFT0pURjOIGLfDtR6vBZsVBBsR65IHEBnUgJz5otqdXu7Cph49eWHfPaOKB9+OT68= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=laf5RzFTQ4DDGgbbeiETmxCBclvlvn5GA+SqD4pwzqXwGFCajLc3/5Nez514OkBikl4YAnpPulqw39PWHwQ8Au6DTggx45/lTJJDeYfugxFRScjileFWRBSoRwedSviBZEOMuSI9Cy+jdiFvjDuU1/LuZyN1bR/pisTfqH5ZF7LmdCOCQvU5z6qBkmqDA3c9I/WIpw31oaYy1KGgP6xvinUQZq5v3CFH+fiF8K+JdnjfL/eK2YFvdhUVaUrKgArLwAVXtMiqEKir+TkhMbt2UBiNZBWybYUt2LoDotynC8U74m7+xAxhnlkwCtWfqVcA0/OP44uPd9EKNJiLr4+SyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3QqT43d+n6B5cmRqYsGQz6h0AS5LY+Wew0+rb1cQAlk=; b=tg2wg7+ghgSa3hfdwevn1elMJZdxLLvRMlcRhT26IqkCjZOo9+QsuVE6Lp83qACoChERZaqjO4E4BSxeU+RvuPHHqn+HfBzlQ7+YICGcsLK9/iUQm0FXT7Y6fciju4X1onLo27hmxIEA1EEkDtV0zOIf8qbXziHfunmXekNds7Wg7JQsPsVvYHVM/If5abg8MOmocmkdiqo3FpeVoL13Lx5Rzr3ZuR1DgFkZS/M4+1LExmEEDQNsZhBJ3IbWPvNKV2X8AZEc7/nNLkU5UGh6cPqgvCWAlYMXjtBXiulCvA1bovts7RZOxpOw7hPt3slQWiVeT/FW4gT3kig14cQkgw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3QqT43d+n6B5cmRqYsGQz6h0AS5LY+Wew0+rb1cQAlk=; b=qHth3AFIizNpoaOgI27EDqYzwWyDCbJfe4Z0Y3E+jqN/4VydWQt1VFoz8ObGe3X/bt7I6t2s+p3Mg8oD8Szixd/gXdGmSlBg3gQqsImgSo2fXepNpSs/h0vG+4zFhyOXs9pAsq4fpqePFTnsLadfAceIlES9it0rsCUSmXAl30M= Received: from AS4P189CA0063.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:659::13) by PAVPR08MB9884.eurprd08.prod.outlook.com (2603:10a6:102:32f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Tue, 27 Aug 2024 09:55:23 +0000 Received: from AM3PEPF0000A790.eurprd04.prod.outlook.com (2603:10a6:20b:659:cafe::89) by AS4P189CA0063.outlook.office365.com (2603:10a6:20b:659::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26 via Frontend Transport; Tue, 27 Aug 2024 09:55:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM3PEPF0000A790.mail.protection.outlook.com (10.167.16.119) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7897.11 via Frontend Transport; Tue, 27 Aug 2024 09:55:23 +0000 Received: ("Tessian outbound 7d86ec5dfeb5:v403"); Tue, 27 Aug 2024 09:55:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c979d400cd85b21d X-CR-MTA-TID: 64aa7808 Received: from L35d6ffef03c3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8A7E4309-FC17-4A8C-9E1B-C120A61E27F7.1; Tue, 27 Aug 2024 09:55:15 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L35d6ffef03c3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 27 Aug 2024 09:55:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s8ivEQv6j9CQt8Lw2XjdpK5UzzHUN+X5Do0c89w614GVpI5bBGJx/C+MYkF2SPEwXMKirTO0Nvl7hrZASdbxkvoXcbGLeJxOu/fJUCvH1hsXg6U0xnQ+c+lmJuWojJclDwvuZ7zUFE1lH9hEEZWsL/HtuGkYSpwZyvXumj7o3mRNlxJm13zG+ACMll5hpF53W+D+mJ+1cZzuw9mD+Nu108ca7BxaBDAeSOZ2BMS7+1Ac6jHZgKCwmsOMd2Miph9GZbtCbPmj0LX7zGux5BngqjSbK5IJ9TXpW2EZu3sjbyet9Scee9CbXUkCO+FuGWoTlP9svmMclcij8XkRP4Ru6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3QqT43d+n6B5cmRqYsGQz6h0AS5LY+Wew0+rb1cQAlk=; b=na8J2grPUz2+KQP90XQtpZn0ZXy4z5ggw7hpxl3MFR7zmynsL8nLFG0lT1iHvPYcrRWgIbbXucJm9NyH2iRky6FgsLR4Uw77LyWIEjqsKwxI1dyC99dmzO7vIQ0WCJCLcbW1BRoJOvdeoSzjgDs4ixlZcdMJsTj1jIgkvNc88w4uxmxvBfzRRJ+n3m6SlU6SHoOf66HATPD3kGJM60QdDzbKjnlTZmcFuK255QbSrRQrHzHzKCwPW2xOGEkCYQQsc2S8V4P9H0LCPvlLzCS40lZA+CL5D6V1wU3EXTqELE+EepGcrIF/trNqeVcZQLtwuDaBpWHEvWlH2/9TTaTP3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3QqT43d+n6B5cmRqYsGQz6h0AS5LY+Wew0+rb1cQAlk=; b=qHth3AFIizNpoaOgI27EDqYzwWyDCbJfe4Z0Y3E+jqN/4VydWQt1VFoz8ObGe3X/bt7I6t2s+p3Mg8oD8Szixd/gXdGmSlBg3gQqsImgSo2fXepNpSs/h0vG+4zFhyOXs9pAsq4fpqePFTnsLadfAceIlES9it0rsCUSmXAl30M= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) by AS2PR08MB9987.eurprd08.prod.outlook.com (2603:10a6:20b:645::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Tue, 27 Aug 2024 09:55:13 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::9f32:dc2a:5bec:aeac]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::9f32:dc2a:5bec:aeac%4]) with mapi id 15.20.7918.012; Tue, 27 Aug 2024 09:55:12 +0000 Date: Tue, 27 Aug 2024 10:55:10 +0100 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , Jakub Jelinek Subject: [PATCH v3] c++: Ensure ANNOTATE_EXPRs remain outermost expressions in conditions [PR116140] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P265CA0180.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:311::11) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|AS2PR08MB9987:EE_|AM3PEPF0000A790:EE_|PAVPR08MB9884:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e2e3d34-79f5-4448-0256-08dcc67e5ea9 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: ARAibBokrSrk6+gKTjjPYJuoRmjTTefvnlfLg31kpFMrrnz98L4BYmyR1f/qjQ+uimVal4ToO0+K3KbOJz/a+ncbiPDJcueajOQep5sygACud1ZmchwiGAci71j4ZUyNMybAjqhOLmj9UnPMBHeUijnif3FW4NaTUkEM1lM46Ps4Nvcf9Q17C1Cs2V46ZltxxIa7+yAVW38/CEpXMDu2pE9xfX5y+jSXYu+8SBSQW7/qNnuAAlrxKY4F5w3cROVwicqVwcK7eDv+00cQ6fkT9xh0OjaP4ITfHd+6W3uZmlqNI/wTLV5oyVPFfbM6z17UM+6kx8BtEVotvIVEJvy46I0d+ptSrpwxtEqhi9T6YTnp72drf4ubRyDWi8mHAdlRS+ROwCAP+dF5Zx0ufMhT7Nboemt2jX1OcPMDSa+kqz+FWAwQJrNuweqTDj3sFHEAp89xz5pLnAvgLydj+6I+56LltKorge79aGKKmoOb0cpXRzNrfJQtQA7jp7SKUFGL06409kuDN1eNRfcwwUPqopJTV3c/Q4JNDEIzb7pTdu2Xsm7KbA1+inHKF0iotKmUCJ9kDV8kpsaiTQbmtdWPPHqdZ0Bcz6Zjn45dzvtzoAmxS2rUlazn5Yr3BQrVcmOXMmCnYtpQ48TXIWz1ddBlENy5DARo+faZEbgGJO9PDExIMGbJQboWYrHdf3bgcwyXlaS0AuHfi6Nt8SJSD3d3BMcGwwl7VK+slmBZmWbMW0jX0PXHJUoIsI7xjzkUNTbZCCubsqFLuiLM/JPhEELkIiPiSPWY4R0kBy0FbIbLnB07pl54DP9FfcuX9RLLtRZZtvDTPaEUHYRDTSFS57Bq9Sm98+sBA0Dynq9it2PR4D2+a72jrGCe9G88Xyja6BMvyxKBD19aK8Rxi930REntQxfnrlB+NtxIYD/sKkNq7PL62QokEkpulADLS9Euu/YrLApwxqDy6dfW1uX1HUa5MS7JsLvwCa7jwTsAVD57uDHb9x1zwUwz5um6YkuOKx+BinrEjhkTXgxjLSUbQrmgXNwVw6DV2w95fS0UokA+1Qv3QzAUGQEnH6MZNmSR2Dky6M8w2YwBc+8VwcaXVBFd9EKiom7sRKrMuYDytuwMoxlRmjUd4AE2tO6B2jbpo0FsWvzSip50RdoCx/57oH4JjLC7/HJKQcjHU4KDQzLR8sHehuwv89ruzKb9WPDAKTK+arcL7x5pWPBtnzA6nurAxV0ANi7vg4tdPRYIna9NZPmSdQepYix+X2XYip36/eGQF4oZD9BuQC4hmCP9PHFmlVQ/L9la/hqfUoR3g+nsWyo= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8958.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9987 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:102:33e::15]; domain=PAWPR08MB8958.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF0000A790.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d39ad1c8-e8d3-4390-5c4f-08dcc67e5807 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?52rlrygiAk1d+R0EngeXUttZnWuZenf?= =?utf-8?q?tE01q5UYIwDnvv9p/dpHQkH2ru21Tu0HIOof7JNfx0uRr/Cf7+vmN63Q7NNByelu5?= =?utf-8?q?Z2r/Fvv+5YbGlnbcX8JDlycqmvkJ6b/Hx2TwaHGnq5Dy8AcB3leYSkHB1aGzqFJos?= =?utf-8?q?E8q3gKm6m8iHQ5fEruSaRbgYqDM4bv/AJjy2r9VHdqDK5sPHELnYBvzpwqUpGrjiO?= =?utf-8?q?kld9ONleoKew69ty1kbGD+AvSLSKh035CBR4kr6a0MeY632bw6MGiOSCtCo4uZeNs?= =?utf-8?q?dgLkZvZUVU5xQn9KVuEXGo07nRhtstaHoZQRVAaxk0T0f5slaVFohNStHdp32HaVQ?= =?utf-8?q?ZOkRM5k83fnYd3F4gJh7YQQME0G2ff37BK/cLzIKhkxYob51S2vBObWFHCgw6wE/l?= =?utf-8?q?uT7fv1iPwN9UxyQV/ihANlMpwd2IduQfIlkDWh9HOaCCs1gdZ62HnKljmozcSbOOf?= =?utf-8?q?h2ac3kgk/PXqd+pejMjwj7NvBH4aWT4JfKKXmbutHzvHypJE0jZiK+/GwcFCwXiqh?= =?utf-8?q?uRGbLCN6s2/jGZ0Q6LhTy/2iYiE4y7+3tIEXrD6utecANSc4qSwiqBlpusT0A2C2E?= =?utf-8?q?MTnFXsy4lZCRByCjnKki+4acfYJz/9zFJMg2LhzWxtVRTnHT8eXOlDS3ha2GxR4W8?= =?utf-8?q?FNfzwhXQiZtqX2q6oc6xO3NrYsVDUaUnXJQ6KchGzbYw3GIlvkWvncD6RS5ih4DAs?= =?utf-8?q?axq4zUizhvXPC/AlLwr+ROFFdh0c2dJaCLkj1eml9pednKz4n8Yww95CCVYPD7Kj3?= =?utf-8?q?Z9wbi7vhxBNl9FYPx35DhgUOR01382Cbe1rOw8aZmuxPAUgmKAGyoSuQFDBnIywBD?= =?utf-8?q?h+eJ62TLP7zupdlVpuoLew7Xpywe3DtIDDwT1NYQOkGq+JD0ofQXJihCLbKSRZZHw?= =?utf-8?q?s7CvVM2U6AyUAf3UMDshVf7/7ORoxHFJlOQq1IycV68Romu5dfKd3sQkG+/cv+K81?= =?utf-8?q?Z51OPMNLidYsoZ9Yg1NrPCVVbutqNaljZHpkiJn3mejBYjdGgApX8t6TFxJgEkan+?= =?utf-8?q?TWSMfHWMaQ9RCKXuiEYdQg2SCFOr7An7T/HmIrWWxgMnMDXIHJSdAj3M1p3VsvHSg?= =?utf-8?q?7z8cTnh1bOFexv07try8aY8nyVMZNhhUnVY/2f7Fa5kqcJR6deZr0NlP7hse6LM/X?= =?utf-8?q?lTN8EGYx0eQvlN9huAapS3sr+hK6thDbgFdaDFRzzyzFJiaermaE9iIReriGApua3?= =?utf-8?q?JclyCCQ3U5v40kETK0vj23JdHUEhUhQHhyOJslCQu2PTK4O2n++BvgzBzXI9YS+OA?= =?utf-8?q?7+1TB18d9ixaApnYtPHRmrZIFGiPXaqThzBC3z+o5IdyBztVDuEzZeiedTAXAf3rL?= =?utf-8?q?YyKN+QAtUkybx4LalxIPU+Iaf1oxJ6z/GA=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(35042699022)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 09:55:23.5299 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2e3d34-79f5-4448-0256-08dcc67e5ea9 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF0000A790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9884 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham 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 Hi, This is a v3 that hopefully addresses the feedback from both Jason and Jakub. v2 was posted here: https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660191.html (Sorry for the delay in posting the re-spin, I was away last week.) In this version we refactor to introudce a helper class (annotate_saver) which is much less invasive to the caller (maybe_convert_cond) and should (at least in theory) be reuseable elsewhere. This version also relies on the assumption that operands 1 and 2 of ANNOTATE_EXPRs are INTEGER_CSTs, which simplifies the flag updates without having to rely on assumptions about the specific changes made in maybe_convert_cond. Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk? Thanks, Alex -- >8 -- For the testcase added with this patch, we would end up losing the: #pragma GCC unroll 4 and emitting "warning: ignoring loop annotation". That warning comes from tree-cfg.cc:replace_loop_annotate, and means that we failed to process the ANNOTATE_EXPR in tree-cfg.cc:replace_loop_annotate_in_block. That function walks backwards over the GIMPLE in an exiting BB for a loop, skipping over the final gcond, and looks for any ANNOTATE_EXPRS immediately preceding the gcond. The function documents the following pre-condition: /* [...] We assume that the annotations come immediately before the condition in BB, if any. */ now looking at the exiting BB of the loop, we have: : D.4524 = .ANNOTATE (iftmp.1, 1, 4); retval.0 = D.4524; if (retval.0 != 0) goto ; [INV] else goto ; [INV] and crucially there is an intervening assignment between the gcond and the preceding .ANNOTATE ifn call. To see where this comes from, we can look to the IR given by -fdump-tree-original: if (<::operator() (&pred, *first), unroll 4>>>) goto ; else goto ; here the problem is that we've wrapped a CLEANUP_POINT_EXPR around the ANNOTATE_EXPR, meaning the ANNOTATE_EXPR is no longer the outermost expression in the condition. The CLEANUP_POINT_EXPR gets added by the following call chain: finish_while_stmt_cond -> maybe_convert_cond -> condition_conversion -> fold_build_cleanup_point_expr this patch chooses to fix the issue by first introducing a new helper class (annotate_saver) to save and restore outer chains of ANNOTATE_EXPRs and then using it in maybe_convert_cond. With this patch, we don't get any such warning and the loop gets unrolled as expected at -O2. gcc/cp/ChangeLog: PR libstdc++/116140 * semantics.cc (anotate_saver): New. Use it ... (maybe_convert_cond): ... here, to ensure any ANNOTATE_EXPRs remain the outermost expression(s) of the condition. gcc/testsuite/ChangeLog: PR libstdc++/116140 * g++.dg/ext/pragma-unroll-lambda.C: New test. diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 5ab2076b673..b1a49b14238 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -951,6 +951,86 @@ maybe_warn_unparenthesized_assignment (tree t, bool nested_p, } } +/* Helper class for saving/restoring ANNOTATE_EXPRs. For a tree node t, users + can construct one of these like so: + + annotate_saver s (&t); + + and t will be updated to have any annotations removed. The user can then + transform t, and later restore the ANNOTATE_EXPRs with: + + t = s.restore (t). + + The intent is to ensure that any ANNOTATE_EXPRs remain the outermost + expressions following any operations on t. */ + +class annotate_saver { + /* The chain of saved annotations, if there were any. Otherwise null. */ + tree m_annotations; + + /* If M_ANNOTATIONS is non-null, then M_INNER points to TREE_OPERAND (A, 0) + for the innermost annotation A. */ + tree *m_inner; + +public: + annotate_saver (tree *); + tree restore (tree); +}; + +/* If *COND is an ANNOTATE_EXPR, walk through the chain of annotations, and set + *COND equal to the first non-ANNOTATE_EXPR (saving a pointer to the + original chain of annotations for later use in restore). */ + +annotate_saver::annotate_saver (tree *cond) : m_annotations (nullptr) +{ + tree *t = cond; + while (TREE_CODE (*t) == ANNOTATE_EXPR) + t = &TREE_OPERAND (*t, 0); + + if (t != cond) + { + m_annotations = *cond; + *cond = *t; + m_inner = t; + } +} + +/* If we didn't strip any annotations on construction, return NEW_INNER + unmodified. Otherwise, wrap the saved annotations around NEW_INNER (updating + the types and flags of the annotations if needed) and return the resulting + expression. */ + +tree +annotate_saver::restore (tree new_inner) +{ + if (!m_annotations) + return new_inner; + + /* If the type of the inner expression changed, we need to update the types + of all the ANNOTATE_EXPRs. We may need to update the flags too, but we + assume they only change if the type of the inner expression changes. + The flag update logic assumes that the other operands to the + ANNOTATE_EXPRs are always INTEGER_CSTs. */ + if (TREE_TYPE (new_inner) != TREE_TYPE (*m_inner)) + { + const bool new_readonly + = TREE_READONLY (new_inner) || CONSTANT_CLASS_P (new_inner); + + for (tree c = m_annotations; c != *m_inner; c = TREE_OPERAND (c, 0)) + { + gcc_checking_assert (TREE_CODE (c) == ANNOTATE_EXPR + && TREE_CODE (TREE_OPERAND (c, 1)) == INTEGER_CST + && TREE_CODE (TREE_OPERAND (c, 2)) == INTEGER_CST); + TREE_TYPE (c) = TREE_TYPE (new_inner); + TREE_SIDE_EFFECTS (c) = TREE_SIDE_EFFECTS (new_inner); + TREE_READONLY (c) = new_readonly; + } + } + + *m_inner = new_inner; + return m_annotations; +} + /* COND is the condition-expression for an if, while, etc., statement. Convert it to a boolean value, if appropriate. In addition, verify sequence points if -Wsequence-point is enabled. */ @@ -966,6 +1046,9 @@ maybe_convert_cond (tree cond) if (type_dependent_expression_p (cond)) return cond; + /* Strip any ANNOTATE_EXPRs from COND. */ + annotate_saver annotations (&cond); + /* For structured binding used in condition, the conversion needs to be evaluated before the individual variables are initialized in the std::tuple_{size,elemenet} case. cp_finish_decomp saved the conversion @@ -984,7 +1067,10 @@ maybe_convert_cond (tree cond) /* Do the conversion. */ cond = convert_from_reference (cond); - return condition_conversion (cond); + cond = condition_conversion (cond); + + /* Restore any ANNOTATE_EXPRs around COND. */ + return annotations.restore (cond); } /* Finish an expression-statement, whose EXPRESSION is as indicated. */ diff --git a/gcc/testsuite/g++.dg/ext/pragma-unroll-lambda.C b/gcc/testsuite/g++.dg/ext/pragma-unroll-lambda.C new file mode 100644 index 00000000000..f410f6d8d25 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pragma-unroll-lambda.C @@ -0,0 +1,17 @@ +// { dg-do compile { target c++11 } } + +template +inline Iter +my_find(Iter first, Iter last, Pred pred) +{ +#pragma GCC unroll 4 + while (first != last && !pred(*first)) + ++first; + return first; +} + +short *use_find(short *p) +{ + auto pred = [](short x) { return x == 42; }; + return my_find(p, p + 1024, pred); +}