From patchwork Fri Jan 19 09:04:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 84409 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C4BE3858C2A for ; Fri, 19 Jan 2024 09:05:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2088.outbound.protection.outlook.com [40.107.8.88]) by sourceware.org (Postfix) with ESMTPS id 476253858C42 for ; Fri, 19 Jan 2024 09:04:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 476253858C42 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 476253858C42 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.8.88 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705655089; cv=pass; b=jMvVzRDS+InM6TZoQUVkS4IXgxCPIlZnVDgF7JyTUK61cbTz2KV+09ZO2sBOrq7wOROa3kpDFynwURHm8NmCaQw5OetvcnRihnBUbY/xPwC/Ey5saMKwrlxyymWNPMDgSCAqyP39QoS2TiR3EX/ES3nEKQGA/VLqo06JvmU3PYQ= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705655089; c=relaxed/simple; bh=y6vdRUzO3s7cN7ghGA+US5cSgnK+a99bK8oX0tfwmhY=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=F9J+tt2fontYCz5VqYLpWozKTBbXtDuHbTdbojpqKwjgfdlyLS+r+hmaeKBJHPjyCXRlJEw2yr2PO6fh5Y8DBGLvIXWqVVh2XEX3hRpsv4AfCU3aP5IepxINGzZuqPK4dDt8CHylTNv7i2aVziiqPXTU7Cb8EV5RzciCBAoDDYg= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=C7PfMs/qQEJKECr/1DLqd081fmHfqGggmd8mnwyEvOtAioFkDWwkRulP4CTpcpfwYGsRqipvehUjUXQGeAootAxGy8IN/2/VjMUrPPZZx7ZIbllWgZYT5USy+VwC5ilQbUZXYbfhLcbGwzPtGvfpYE6VEdlRV6XBboz2HAfQ3K+BvbIvrhQRsFTaAlBnA6OQ4Qe6k2U81pO3fdfUBRwkGGNbEwkmOzDGfmHJo7xVcnCF1g/fvVzwFs/YVA09eEqRbjnjOlPHe4WfU8n9NluQT80wlKfPf0Av/pvvPGXOOOYYAPuSvTGCwho5DN6xPC1b5+h3j75VlyC0Nzpo5NXfaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=r6QDyDRiVfIzOexU4aVRXlWRoELRm0nTD5HNeaIsAoo=; b=JvKM3zKTKS40AbTaH4mHPLFki/4dRHjVhyoGmh8yCvfzFysoVFnRzLLPR6kuNRpj78zxu+8qIH9f2wDgiXItkIgTP5LY39uLNBcXqS3McxUotqAwZQQaQln+i5W7uhesSHOXIWwDzQe7Vct5uDdgQX7gdIzttcEh2uKwI+8nJjOCoI2HkWRQu+VjTUjjUIDjQkbhiL+cmJGjENdWZb7MFfvaPYvcDKcqE1gCSBHlTLMAmzAH8QzXpH0mXT9ezYonknl4ejX5OloP3++AMJstqxKDcBpw61VFgTAFpMu7NhfsLshG+3lrqvJSS/gN4hVwj0XVT5lqSdHOEskKMlloCw== 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=armh.onmicrosoft.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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r6QDyDRiVfIzOexU4aVRXlWRoELRm0nTD5HNeaIsAoo=; b=d9htlhCA98rhvpYHLRJH3CUsU4TDAbdmmFnw2UEiQiJGjmZ2B512HOsGo92iNOollpGgr46YrOkAF6Cefu1/FNHg8o8/npF+VTo6V+D495vJM6Xs/hLEvrEm/gaHVLR2yBWcYgj8dMlVog5I9g81THRjvWft8nYqONlGT8JCxCM= Received: from DBBPR09CA0040.eurprd09.prod.outlook.com (2603:10a6:10:d4::28) by AS8PR08MB6117.eurprd08.prod.outlook.com (2603:10a6:20b:292::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Fri, 19 Jan 2024 09:04:35 +0000 Received: from DB1PEPF00039230.eurprd03.prod.outlook.com (2603:10a6:10:d4:cafe::9f) by DBBPR09CA0040.outlook.office365.com (2603:10a6:10:d4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24 via Frontend Transport; Fri, 19 Jan 2024 09:04:35 +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=armh.onmicrosoft.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 DB1PEPF00039230.mail.protection.outlook.com (10.167.8.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Fri, 19 Jan 2024 09:04:34 +0000 Received: ("Tessian outbound a297577ee0df:v228"); Fri, 19 Jan 2024 09:04:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ffde4946e76be595 X-CR-MTA-TID: 64aa7808 Received: from 6e445a9994e9.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9419E0B7-F220-4FD8-96B8-AB71ADC48E9C.1; Fri, 19 Jan 2024 09:04:28 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6e445a9994e9.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 Jan 2024 09:04:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a4EZaxkAOGy8cC0rX04vSyS5KaCtP5k92ml5JQ/mpjmyhGitZXH3PUOdJl6ENDL5Pv50TcXrx7saPOEQ8GYT6otq1OiVxiexaNLw2/iEJ2C+edNTGHHYPXk0peTWzBOpQKXlvgpY+YK27n/9w3Gc4yyKyj0nU9xG3393SWn8pD4Yb0DXJOPisQC8sFl2j0y+2H4dw0qEPg6vYYk4xwCdBiXyAIOvNNVoJqZ7Zn64tNnbWMumV7jThefXqWdYj3wf/9iPjMKZsp4/o45jRuR87biyoyIxg/VyG0/9xMYCKl527nAwmsQHq9Aj9dw4BCfk+ZsnloA98IQTImHzNoaJ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=r6QDyDRiVfIzOexU4aVRXlWRoELRm0nTD5HNeaIsAoo=; b=Q4dbFPwhmhku9By8fnUM2uD1J9fE2DgrrZZs++QFho4lLqV0XM83uJxuNHH7w5uLqzTYDhtFKtzR5dqcgJ8RRTOt0F0XZ7cHeMv6Sx4VRk13/Chk4CwrYD1CnstYGJEPvSToJc3lyenHAmymIBtJcJmcpJtA6XV+RPACO9MrxqS1tcA0a1iTU0vddNPSEdewZPsSugx8Apjx6fAvTVAqZ1CZ6kOyMtObSMHgJm2d/2yQL7jcax2S8RuwnQVfvNNNooFXapBb5LpLbMCShI2V/4JlGH9Isq+cRzXK58qYSoMSnWEfDzDK4OolNnMjhZ5e/v3L/RdfP02o9ygnww1t6Q== 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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r6QDyDRiVfIzOexU4aVRXlWRoELRm0nTD5HNeaIsAoo=; b=d9htlhCA98rhvpYHLRJH3CUsU4TDAbdmmFnw2UEiQiJGjmZ2B512HOsGo92iNOollpGgr46YrOkAF6Cefu1/FNHg8o8/npF+VTo6V+D495vJM6Xs/hLEvrEm/gaHVLR2yBWcYgj8dMlVog5I9g81THRjvWft8nYqONlGT8JCxCM= 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 DBBPR08MB5931.eurprd08.prod.outlook.com (2603:10a6:10:1f7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Fri, 19 Jan 2024 09:04:26 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17%4]) with mapi id 15.20.7202.024; Fri, 19 Jan 2024 09:04:25 +0000 Date: Fri, 19 Jan 2024 09:04:20 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford , Kyrylo Tkachov , Richard Earnshaw Subject: [PATCH 1/3] rtl-ssa: Provide easier access to debug uses [PR113089] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO2P123CA0039.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600::27) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|DBBPR08MB5931:EE_|DB1PEPF00039230:EE_|AS8PR08MB6117:EE_ X-MS-Office365-Filtering-Correlation-Id: 9985c909-377c-498c-3a30-08dc18cda83d x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: p3MbuWVIsRc/tKtX5BgkZobIJMldL0Zb5RfopY+C2IkMBFH9v6DlhqrAXkG6uL8rka7fbD8QJhC5Jz6o2ctMBL5jGmJ058ojNM+d/D/8IIHZLLytdn6a5zOUo1mC7nUp1cjcuT/DCL95JqiokAbYYDZ/C9c6gmMoZ0+EjNjxF2GZyC8AylQepp3oT/5EIOP/YqbjEMWcpzNz9khVfC6u4tiW8f4doUYCaYEL43UKq0lcEMj7CVL5UD02h8IZH+Eci/tsbAamtC65FUkXTGznvvr6P9YhV5hP3Eiyh0eEVSEINCWriDe4Pd+81/w0OUQzpknNiXRke3jjHbQ6kTiVkliScYainxFBGLAbygvknPxbsVqBuU7Bsglzp54anuwrh+k5eBkShNOaHhCxTBoCjtjRlv3YbPu5U9oP8juqqoSjl9f6ERMsVx2tVUHi5CMgL2uePOks1JqywXlkQUok3zwa29EIe8HEVfwNPws1jcryqOIYnNj5g1W/Tm9q0l/Hnogm3uPq8mHKN0dRxzk/jvQOoV4fMi6fSiB1SjRDs4KoFSfqmJgRNrZwZX5XxLwdnnVp4J+NPSqB4Ahd+xDoQoFtt6eoh528KvzOyBymc5QK10KVYSEDDULmZ3xUdLv1 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:(13230031)(376002)(136003)(39860400002)(366004)(346002)(396003)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(83380400001)(44144004)(2616005)(38100700002)(33964004)(235185007)(26005)(8676002)(5660300002)(6512007)(54906003)(8936002)(4326008)(6506007)(41300700001)(6486002)(2906002)(6666004)(44832011)(66476007)(316002)(66556008)(478600001)(66946007)(6916009)(86362001)(36756003)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB5931 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-Transport-CrossTenantHeadersStripped: DB1PEPF00039230.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 832ef21e-ec73-4409-d634-08dc18cda258 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d3AA1A0jiHzdGlSZBL38voP8xSjJE2oRkWFOw2lwhyyod94eITNBYUmZ6F/vGAUGEkE5uZUYUHt6MFOyYHt6zJdJS2mP84fEkFOq6MAkOobK7aLlAcPrCPlwjCwCRvKN9gr6/J1QtJoNOBp3LLwS7MDEwoeHTG8SYVOBIwq3GZt0Gw4xlWQ1AFlm81NBRz4zbDxuEVP6f5mO6LpaQefksQ8uB3EMzxPQZVHgO1M66/zWISqsBemnyDfp0y610nMpBPegkeGgqAf50iFJiE7ORYIXoFfvA1wmoPmzGHs5AOvg0Ab5QXVGy04RZbc9hJyUhxWzI1d71TsSyqLQv/Zv10XENp9r0QKnO6qAo3RBCUfs5/GtXsW0OaPHRDTLOApi0BlOswOGka+YOXUEVyySVYsKSZthKyzKGVGpcYe40aN1FAcOHX8Ybq4itIgOSXJpjB+ddab6TK/zUSyAM0HsR0k5K5jHH1vqoZAASCdWUyDVy6uusW6VkFjeuChfq88hh8fknVnnQrr6l0fNzf8JSF5LXJqGD2RKIt0WcCs1xrQDrV7fP8CxqdKX7GacBYJtN/ID9cZBOu7ccIBfRpjrkFdTEOQOpIh0z9VtjfoV0iuUuhmx207HxIjRsjK9yvGlgowg1DJEBvBI7PwcBZTtVjjGafnntKTF1f2bi3fB1ynoN9eEQc1Rapw8KnhFNu1LIEgLttkhsydImvUgdkgYi6ZXoP0ZEkyWSHNKDuz67b4HWGbe/FBCnGXbTtxW1b6sp9uRzmmwlUPp6JmkhPOj5g== 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:(13230031)(4636009)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(64100799003)(82310400011)(1800799012)(186009)(40470700004)(36840700001)(46966006)(2906002)(235185007)(36860700001)(36756003)(41300700001)(86362001)(356005)(81166007)(82740400003)(54906003)(316002)(6916009)(478600001)(70586007)(70206006)(6506007)(33964004)(44144004)(6486002)(4326008)(8936002)(6512007)(8676002)(47076005)(6666004)(5660300002)(83380400001)(336012)(44832011)(2616005)(26005)(40460700003)(40480700001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 09:04:34.9714 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9985c909-377c-498c-3a30-08dc18cda83d 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: DB1PEPF00039230.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6117 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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+patchwork=sourceware.org@gcc.gnu.org This patch adds some accessors to set_info and use_info to make it easier to get at and iterate through uses in debug insns. It is used by the aarch64 load/store pair fusion pass in a subsequent patch to fix PR113089, i.e. to update debug uses in the pass. Bootstrapped/regtested as a series on aarch64-linux-gnu (with/without the load/store pair pass enabled), OK for trunk? gcc/ChangeLog: PR target/113089 * rtl-ssa/accesses.h (use_info::next_debug_insn_use): New. (debug_insn_use_iterator): New. (set_info::first_debug_insn_use): New. (set_info::debug_insn_uses): New. * rtl-ssa/member-fns.inl (use_info::next_debug_insn_use): New. (set_info::first_debug_insn_use): New. (set_info::debug_insn_uses): New. --- gcc/rtl-ssa/accesses.h | 13 +++++++++++++ gcc/rtl-ssa/member-fns.inl | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/gcc/rtl-ssa/accesses.h b/gcc/rtl-ssa/accesses.h index 6a3ecd32848..c57b8a8b7b5 100644 --- a/gcc/rtl-ssa/accesses.h +++ b/gcc/rtl-ssa/accesses.h @@ -357,6 +357,10 @@ public: // next_use () && next_use ()->is_in_any_insn () ? next_use () : nullptr use_info *next_any_insn_use () const; + // Return the next use by a debug instruction, or null if none. + // This is only valid if if is_in_debug_insn (). + use_info *next_debug_insn_use () const; + // Return the previous use by a phi node in the list, or null if none. // // This is only valid if is_in_phi (). It is equivalent to: @@ -458,6 +462,8 @@ using reverse_use_iterator = list_iterator; // of use in the same definition. using nondebug_insn_use_iterator = list_iterator; +using debug_insn_use_iterator + = list_iterator; using any_insn_use_iterator = list_iterator; using phi_use_iterator = list_iterator; @@ -680,6 +686,10 @@ public: use_info *first_nondebug_insn_use () const; use_info *last_nondebug_insn_use () const; + // Return the first use of the set by debug instructions, or null if + // there is no such use. + use_info *first_debug_insn_use () const; + // Return the first use of the set by any kind of instruction, or null // if there are no such uses. The uses are in the order described above. use_info *first_any_insn_use () const; @@ -731,6 +741,9 @@ public: // List the uses of the set by nondebug instructions, in reverse postorder. iterator_range nondebug_insn_uses () const; + // List the uses of the set by debug instructions, in reverse postorder. + iterator_range debug_insn_uses () const; + // Return nondebug_insn_uses () in reverse order. iterator_range reverse_nondebug_insn_uses () const; diff --git a/gcc/rtl-ssa/member-fns.inl b/gcc/rtl-ssa/member-fns.inl index 8e1c17ced95..e4825ad2a18 100644 --- a/gcc/rtl-ssa/member-fns.inl +++ b/gcc/rtl-ssa/member-fns.inl @@ -119,6 +119,15 @@ use_info::next_any_insn_use () const return nullptr; } +inline use_info * +use_info::next_debug_insn_use () const +{ + if (auto use = next_use ()) + if (use->is_in_debug_insn ()) + return use; + return nullptr; +} + inline use_info * use_info::prev_phi_use () const { @@ -212,6 +221,20 @@ set_info::last_nondebug_insn_use () const return nullptr; } +inline use_info * +set_info::first_debug_insn_use () const +{ + use_info *use; + if (has_nondebug_insn_uses ()) + use = last_nondebug_insn_use ()->next_use (); + else + use = first_use (); + + if (use && use->is_in_debug_insn ()) + return use; + return nullptr; +} + inline use_info * set_info::first_any_insn_use () const { @@ -310,6 +333,12 @@ set_info::nondebug_insn_uses () const return { first_nondebug_insn_use (), nullptr }; } +inline iterator_range +set_info::debug_insn_uses () const +{ + return { first_debug_insn_use (), nullptr }; +} + inline iterator_range set_info::reverse_nondebug_insn_uses () const { From patchwork Fri Jan 19 09:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 84410 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F08D385843B for ; Fri, 19 Jan 2024 09:06:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2078.outbound.protection.outlook.com [40.107.8.78]) by sourceware.org (Postfix) with ESMTPS id A80AB3858418 for ; Fri, 19 Jan 2024 09:05:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A80AB3858418 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 A80AB3858418 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.8.78 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705655126; cv=pass; b=SC3K/XvKWC+KFkcpw+dVNMDoWINwPcTfr72NjV9HPgh3gVkBRMrG53SFNztailrChC1RW15B29sWuhnIm+22hxxE04ORePdudJpR+s5a5KXOYb9cKTF4+WzaDYIjaIOGR6F1zUau0n8bzvNAQksJ13DmDlKZllffFEHANvalV3A= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705655126; c=relaxed/simple; bh=dO4THXsKHQqbDDr9LHPYh01zDIzK9/CTRa1Srs0JEF8=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=MaRAiBg+sWIUuQy/qujmukneJNYZ44MN7/G2+8cx0F+Hty8YLaIc/AFVhkJvduCEfcyfHe4ElWcNksXMJYQEwogAGsmtd8S7cOp8UYn+rjh0YRqCR9tMW10zwspMEgECz38njCfNHS01G4SOQ5MpI66aZi91ggZk1BlbDNIp+nk= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=bLqGmghb64lC39NxsXuLYgPSPLrovfh4/ukDQU9e90JetZ8+Zd0Vn3va5GP1SnlyFLRxWYpI8kxuZr6MXNh4XDLlfst+WEY9jVk+FfvwURrCkbXqLjGKroLPQs09mkFhGPMEo3mHJRR4katEOUvoqtFjO7JpH3yrTf9a5vSSkOpOQCRMmVMf/chJI3MB2XJ1xpOTE0MNX+S1oS1SMeXIRntHGejT9sXm6WXKgkX/AQ5qPTIMvPvTau6PnRWhS3CdhIut60ONwXoXWF7Pbne8KBVIhTIQAXsnBJ8UoR9bDQAu8GAmoA7Eg4NtW0YKBv+4uuzXk9uYhMUXsYxgqbBK8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=cTMZ+voPlpnVvgSYqTBFzMkceAK8oxgn4qAUGCxk3sc=; b=eMqCgfutdLOzams4lc/KIORETOSnJNizthQr5KQ/OL8xoQ3C64KUov+98cbxX3/f/1hNyuVvUNhxH0GSa6AjQihczs9C6G5cnzZSGiWfpxQy5R9ybmM+7dEb0EMWvdD8LyY3HTBdoDwFq2IEXUl3f/gBzFEby2m1abULSAw4EY5/6CKqytw5Nzc/3VCGXmRHSt/5mgetaxD5RHMeMhUOX4AQOn7fHduzWGNvQ1UMoBr/gTEKXS7tTxq3QNpbxLwUliJeLVyDmMbWNA5KKOjv4HF66VnxXGG9i6k90OtFPcKe94FS7Q6sIhgV8I8kAyBD76Q8QFGzWy8upj+S8AyN9g== 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=armh.onmicrosoft.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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cTMZ+voPlpnVvgSYqTBFzMkceAK8oxgn4qAUGCxk3sc=; b=i3Ww2k844QpJvyxRSYOYlWtqdCDedG2j8suUxBTmP3bxf04DBg4Vxi0wcG2gsZSksrD29y/BnBFwSEbpbgboohh36IBaob7O2XQ0u92+Ndy8F9IGiNqqnMLXRL6jVopuAqDaU5csTSK+uXDYtsEY/tbk4nRy8HGSfh71QdZe/hE= Received: from AM6PR0202CA0064.eurprd02.prod.outlook.com (2603:10a6:20b:3a::41) by AS4PR08MB7431.eurprd08.prod.outlook.com (2603:10a6:20b:4e3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Fri, 19 Jan 2024 09:05:14 +0000 Received: from AMS0EPF000001B1.eurprd05.prod.outlook.com (2603:10a6:20b:3a:cafe::d4) by AM6PR0202CA0064.outlook.office365.com (2603:10a6:20b:3a::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24 via Frontend Transport; Fri, 19 Jan 2024 09:05:14 +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=armh.onmicrosoft.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 AMS0EPF000001B1.mail.protection.outlook.com (10.167.16.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Fri, 19 Jan 2024 09:05:14 +0000 Received: ("Tessian outbound 1076c872ecc6:v228"); Fri, 19 Jan 2024 09:05:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b3ed674d0c3b2b15 X-CR-MTA-TID: 64aa7808 Received: from e6d172d0573c.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1604A68A-9E46-4AD5-8222-6DBA3340CBB6.1; Fri, 19 Jan 2024 09:05:03 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e6d172d0573c.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 Jan 2024 09:05:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dx4OIMi5Qhhgn1n1b6zioMvdJyQ+edQqd1rsoCJ1aZp59CVBfrIHJbNL/YAKx8ekkFeiruHAOkt/4BgwlMpdaIyMS8e0o6wTo8PLJY2nmwpDa0HcZit5233YbMCZCppFLNSBv+hv8blJiAsROb8Ye/vnK69oEE43KiP+kwkD+yss02nWdGbS/e/vDKxDwtD6mPBGcSrr7TolE0pF0lt0Xwsp3YbcgVsh1Vm2kXt440TbxSEey5wfMniNV5eVuvPuPvdkoti1PGs7OK+joJbl+b2pWFkpbJ0E4uqPsO4Wqlv7r+vCjmR2ZSCl6RXyKq0800mAcnreFsNqW7GMpm5QSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=cTMZ+voPlpnVvgSYqTBFzMkceAK8oxgn4qAUGCxk3sc=; b=CSNjk5kB72+kYpG0fOblXUcD/RmszGcwslgIz5FH2a6AD9x8nzyKwafBEXJwRdn6ftgPAMPY13R+3uUaq2uZUjyLsivGP/xM7MYgIVjoLUmX+VRZkZ2TOjFfdr2lKDUEgFcYfkZvybBxyoN5SW11KmUf4ByBffGfaac0Vq74w0QSs0jZSjfF3qjpmlt86q2F/h4BjCv23W9T6xIU3dqpZO4FP/xp/BQ6JUeNTZwHlCi6MwqhvgO7KnJfNP67YoGk1ggYeVV9H2N1ckv8kpGzYs1Zj0/T2BkTdDj1lQykbhil54lkkLMpg5dqh03WbF6BgoXCL2wLaVbu+wm4YwZiFA== 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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cTMZ+voPlpnVvgSYqTBFzMkceAK8oxgn4qAUGCxk3sc=; b=i3Ww2k844QpJvyxRSYOYlWtqdCDedG2j8suUxBTmP3bxf04DBg4Vxi0wcG2gsZSksrD29y/BnBFwSEbpbgboohh36IBaob7O2XQ0u92+Ndy8F9IGiNqqnMLXRL6jVopuAqDaU5csTSK+uXDYtsEY/tbk4nRy8HGSfh71QdZe/hE= 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 AS8PR08MB6392.eurprd08.prod.outlook.com (2603:10a6:20b:31a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Fri, 19 Jan 2024 09:05:01 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17%4]) with mapi id 15.20.7202.024; Fri, 19 Jan 2024 09:05:01 +0000 Date: Fri, 19 Jan 2024 09:04:58 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford , Kyrylo Tkachov , Richard Earnshaw Subject: [PATCH 2/3] aarch64: Re-parent trailing nondebug base reg uses [PR113089] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P302CA0043.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:317::16) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|AS8PR08MB6392:EE_|AMS0EPF000001B1:EE_|AS4PR08MB7431:EE_ X-MS-Office365-Filtering-Correlation-Id: 02ae4661-cf1a-4b8f-de51-08dc18cdbff5 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 2ffmkvytL/QNde8iHvDlMBwyvx7S6IWxleUQCw5L4I5Md1B2OBvIACnqneF+lj7/vWaIVnI7QCkcf4PMUTeKUlgMtk8vsTJLMp4vB8Gn3Mf9MymLgZEi9MhIBBuU/sgBC+7YONZTJJWyJPYRtKnWBrTmvvfNGe1jK0FXjWLKJRHL2AoYLr3uH4YpVZsEr8IuxGSqtPmKt/gRReyC/MdgYSlmKYl3QzzWFl6hCQ6VCN2GVPYhblk0oL6eJXtAOFZ06e6ZLEP9ThzMc+NO5Vwk6/8ufaYet/OWiiRGyVUOb2UX+OIeJu5VP0pFLx9KXfl5QPzekmsN1r8TcZBPGYE4E7kQuYR4rQuSOo0/uXfwFDtFyPRh68++BmjNT15GTvl4qt8Dd3DY4kLlN3Qg1wc6XW5G5RF6/b81/1SiVXLrZrvBcMuZ72NJiSybg/MCyNXrAaLwVAf+c7aVxVr2Axp0eFTeuhYbbq8nm5oVwYLfFqTRuXrGxv0rZiDXrqanyXwlXPJn/ZS9tUVBook5oqQ8dIrQHJQrW+0+Ibo094vH0DnlTDZTLvizz5JpNnQae4MAIB6TXMAFC78QF3ofHHnYFOIHpiKMSt+B/pY/PxgxJrP3BucrYAZPVAuS2OACuL3pif503s4y/ZaDrImDuqgJpg== 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:(13230031)(136003)(39860400002)(376002)(396003)(366004)(346002)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(26005)(83380400001)(6512007)(44144004)(86362001)(36756003)(2616005)(6506007)(8936002)(8676002)(4326008)(44832011)(235185007)(5660300002)(33964004)(66476007)(66946007)(66556008)(54906003)(316002)(6666004)(38100700002)(6916009)(41300700001)(478600001)(2906002)(6486002)(67856001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6392 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-Transport-CrossTenantHeadersStripped: AMS0EPF000001B1.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1791d25e-10cd-4258-49f1-08dc18cdb807 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G5wwKBkFGl99ZUxHTwPqrXbibkFQMOBOv6MjbX4xopzEBdmPuf49soNgT7boyHiXnJ7DECG2uLMJ5wTzGKqo0x5Yswd2iooEn7PCD72OHnXQvI2VMxsHZWA5iswVMHCMJrZwUj1Rt5oy4DazFAGIQY2rGTBuOxIzPMlIkWr2hy7leZYv39+4UJzEwyGkHmf8zu7VMH3zsIrOq9Th1LY4n1Ec1j8XBwr2VfNsR+/gLM2l3eVJNCHW7DVGwaqQLETmK4DuSAqdMHU8BHh4pg80qxb4sEhULhK5HJs7QBnzgG4hXJDb8uzxvGyxa7BsLEV7FY79LbD8/EIhyh04jTVUEAg2yOMJwumbEs2P4KVkl6QF90Qr+1TnkDRiB2+ksu1wa2EjsCyltGQlPYLiPmU3TL0moN5vksHR80Uhf1ZootnUR0ou3HV5ZlmKvCXAbOmaUHcokqZW6RjVGcE/nQWLoFAwgHUb04bH7ErWcLdEeg0BhJ7+lha+lSVR7mQJg/bkF6izYI/ctAsTjPS0coMTK1LhWFHDzluPuJhMtJx76Th/7FD20vX1h1VFzhvans8yitLXK3Gy1+10LZLdxJSZVkilmsvqnWDVI0Hy9Eyg48VYbo0BVslSd5+aFBW1txWZ8R43O9db4VRLhmTrkl6H9ijOjwQLwancQEP/tVgW5zG8baQ136ACZ7Ev2z0wiR2xqsjqi56E6HUP3ttw+KX2j9HCE6A6bHdllo7bjUpBXIqiTQOM3LYoMW8NEM3uC4shXtMs2Ge24xhwTLcZPx0Ujn6mqaO38ekOypOAQSYkZXY= 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:(13230031)(4636009)(376002)(136003)(396003)(39860400002)(346002)(230922051799003)(82310400011)(1800799012)(186009)(451199024)(64100799003)(40470700004)(36840700001)(46966006)(26005)(6666004)(36860700001)(33964004)(6506007)(83380400001)(6512007)(478600001)(44144004)(2616005)(336012)(47076005)(5660300002)(235185007)(2906002)(44832011)(41300700001)(4326008)(70206006)(6916009)(6486002)(8936002)(70586007)(316002)(54906003)(8676002)(86362001)(81166007)(356005)(82740400003)(36756003)(40480700001)(40460700003)(67856001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 09:05:14.7066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02ae4661-cf1a-4b8f-de51-08dc18cdbff5 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: AMS0EPF000001B1.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7431 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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+patchwork=sourceware.org@gcc.gnu.org While working on PR113089, I realised we where missing code to re-parent trailing nondebug uses of the base register in the case of cancelling writeback in the load/store pair pass. This patch fixes that. Bootstrapped/regtested as a series on aarch64-linux-gnu (with/without the pass enabled), OK for trunk? Thanks, Alex gcc/ChangeLog: PR target/113089 * config/aarch64/aarch64-ldp-fusion.cc (ldp_bb_info::fuse_pair): Update trailing nondebug uses of the base register in the case of cancelling writeback. --- gcc/config/aarch64/aarch64-ldp-fusion.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index 70b75c668ce..4d7fd72c6b1 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -1693,6 +1693,30 @@ ldp_bb_info::fuse_pair (bool load_p, if (trailing_add) changes.safe_push (make_delete (trailing_add)); + else if ((writeback & 2) && !writeback_effect) + { + // The second insn initially had writeback but now the pair does not, + // need to update any nondebug uses of the base register def in the + // second insn. We'll take care of debug uses later. + auto def = find_access (insns[1]->defs (), base_regno); + gcc_assert (def); + auto set = dyn_cast (def); + if (set && set->has_nondebug_uses ()) + { + auto orig_use = find_access (insns[0]->uses (), base_regno); + for (auto use : set->nondebug_insn_uses ()) + { + auto change = make_change (use->insn ()); + change->new_uses = check_remove_regno_access (attempt, + change->new_uses, + base_regno); + change->new_uses = insert_access (attempt, + orig_use, + change->new_uses); + changes.safe_push (change); + } + } + } auto is_changing = insn_is_changing (changes); for (unsigned i = 0; i < changes.length (); i++) From patchwork Fri Jan 19 09:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 84411 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1228C3858C2A for ; Fri, 19 Jan 2024 09:07:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2070.outbound.protection.outlook.com [40.107.6.70]) by sourceware.org (Postfix) with ESMTPS id 88A6E385828A for ; Fri, 19 Jan 2024 09:06:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 88A6E385828A 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 88A6E385828A Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.6.70 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705655164; cv=pass; b=Nmtq+RmrWwSPd3TLj4qbTpq+F6CYdtLphor+h+HY7NN26iVdNjvmiGUlLVnJJHJ/70ZJ4bGZ66qoWiFj9TXqsUo8DchFWf8eXJOEM7yCDQV5pCgXHwHDGSd7Bt7zEAIbUtTUd5Vo/R/SSeCzCWfQY9xvFMpb9Fn4AIerlsM5R6E= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705655164; c=relaxed/simple; bh=34JWBUq3Ay04pmyzPH8G4pKKZD89PdqUTqG6xCKyMqk=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=CTKjeyG/GJZMtbs+/qttF+JteygAG9uQYHQ40W88xnkOwFMTVB5XyFhXA+t/4lPLnNqpDNfMK2ZSOxSNS0iHw2biMe8URZWsopZHPE3zOJ1iK2PEHcpyBIoDUEU1RROZ+LeMlqVJfRTyBhMizj2ypt98FAmWtEvuJDx18hYG1wI= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=XRQ3mtwvvt7CJMcGIGadBaIV4m2sTb/Bv8JJTbq07wIQThwtDD31l2Bu2jYmXV5c/50t61Nk1NK0XC8cM9HXE/D05RJeWoX2sOL0nSnOdQlNEBCyD4DAtoua6i2TdFW7rrdj3Jr5F7zK4nzZ6Prhc/oQQv+RY4klIEakTT33DUkcUn3+WO7bPX9xCaKuIfI3wQY9l+wCEKeaIgLmOv18vdwY5/i8qnuN7DeZ9twHIvjoyGTj+OJixmtgKsqQI/etMWBTBk4kDLY7+wDMqeCrTWZHO1ehO1X+iBb6MGkipzw5ikMHaRzStK9Mdbu8Yi0NVPM1z7Xx/BPzOuILG9F5/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=leXMGoi6kwJ8ZpY+mPk6JjEt4QMkMG1jH6UdmuSMBfk=; b=dLGHz5c/TbdLxdOSaDnZwxmtzTP6h91pZLMhT46LcSgR0IvpTrt0gN5fNd5vLmjMhRLHyJUzkEU0ZENOWn2213lZpxVuo515HiWMhFIviaPT2gzixUsEEnGOW5dkveJqaS/FT1HDqFbPs/BW8k8Kbva6QsKlZG/h+/2Ycr48esgApzD73e+LSD3MbkZfgL9uEoTE9H6onpNZNe5PKlaEEvxohgKyo9S6PHsPMggLRe0P63rsXXkGzbyCitgvDXqBfXDsiqgIANqPi0r0iJvV28fdUtqcWsL63JbDb7Yo5nHW1j3dr1od/XyKrnzy0GSeCwf001yXmKZ6iQMYxZ5+rQ== 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=armh.onmicrosoft.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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=leXMGoi6kwJ8ZpY+mPk6JjEt4QMkMG1jH6UdmuSMBfk=; b=CenUNUlRQIN7tQpCNO9ewpAtOCfthyBnbKzvc6QO8zYMK4A+WHsuby+V6tDt9joxfyeq2D6MaldHscMcGI5T2rDDLafYTCYGm1n7hJmDZvwXPZJW+VQc8T6wexR/sbsI8xArwRZ80hKKKyuVLtkFdCL/EL8MK54y9y6iYFHH1pc= Received: from AS8PR04CA0016.eurprd04.prod.outlook.com (2603:10a6:20b:310::21) by AS8PR08MB10003.eurprd08.prod.outlook.com (2603:10a6:20b:63a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Fri, 19 Jan 2024 09:05:58 +0000 Received: from AMS0EPF00000196.eurprd05.prod.outlook.com (2603:10a6:20b:310:cafe::42) by AS8PR04CA0016.outlook.office365.com (2603:10a6:20b:310::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24 via Frontend Transport; Fri, 19 Jan 2024 09:05:58 +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=armh.onmicrosoft.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 AMS0EPF00000196.mail.protection.outlook.com (10.167.16.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Fri, 19 Jan 2024 09:05:58 +0000 Received: ("Tessian outbound 1076c872ecc6:v228"); Fri, 19 Jan 2024 09:05:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3a147b08f5e44ff3 X-CR-MTA-TID: 64aa7808 Received: from f1ac842f6376.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F7D021B0-5E28-4CA1-91C4-47FB70B712FA.1; Fri, 19 Jan 2024 09:05:50 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f1ac842f6376.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 Jan 2024 09:05:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lMk1OJpNU1wqSFHWnOq3Ua1ZeKeg5QLV1Y9EzHeA/KjjAcuZeoRrsfvOMnf3rfA5zjWg4ckcARxyMbkK8Gsk8aCYxT6X18kxBxgNxjRW1L5VcXJOVp56/RBjRL3Mc+UsQfuU5GT0/8/qrPxavx9b77Yus0cWJGeG80+vvp+jfA1j00Lo5cMHo7RjC6Wa58OyBtPqjX64xZRlKjCfN1hqtYVEVWoU3fDvVaHb0OJb1iE6yBsgu6sItDdaBqxP2m0HtG6jbOv3qi47bMlVuFy3Z47U0HW9oLYJ4tNBw0QXck5KsugAzUk3pVlqkZKFskTvt1zgJ3DOm7ecMKGTih7jIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=leXMGoi6kwJ8ZpY+mPk6JjEt4QMkMG1jH6UdmuSMBfk=; b=EkIXZq+ShF5bh6mzB/Fxfyx90HljS6QggLW/n0FbRH4d6aRKS03b4TtAW79lLsMlosSmk569jL1dkBNq44ONxQf8hsF1dPAG1SOYDvwmxe2AUZXEVdfjzQe2ACmosc+cjA9OuyJSmAHsX3fqX+3HJSoy1nOSh7n3B6pfAz5aYsH1wnyviNmQ193uigw9F6xJUTxYWL6N+Bl1GL7m8Xnak4N6VC4OxkeL7sbJRW6cYFgzul9xQMI6+aZoLkkPY1zc2frjppKAm9i7gbLQgwqp4o+k611qcXvmw7/z4kZaq0gWCob49GBbKPl+Ke6rKhMj8H+IovRN2Zdui5Z8PmCl+w== 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=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=leXMGoi6kwJ8ZpY+mPk6JjEt4QMkMG1jH6UdmuSMBfk=; b=CenUNUlRQIN7tQpCNO9ewpAtOCfthyBnbKzvc6QO8zYMK4A+WHsuby+V6tDt9joxfyeq2D6MaldHscMcGI5T2rDDLafYTCYGm1n7hJmDZvwXPZJW+VQc8T6wexR/sbsI8xArwRZ80hKKKyuVLtkFdCL/EL8MK54y9y6iYFHH1pc= 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 AS8PR08MB6392.eurprd08.prod.outlook.com (2603:10a6:20b:31a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Fri, 19 Jan 2024 09:05:49 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17%4]) with mapi id 15.20.7202.024; Fri, 19 Jan 2024 09:05:49 +0000 Date: Fri, 19 Jan 2024 09:05:47 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford , Kyrylo Tkachov , Richard Earnshaw Subject: [PATCH 3/3] aarch64: Fix up debug uses in ldp/stp pass [PR113089] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO6P123CA0007.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:338::9) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|AS8PR08MB6392:EE_|AMS0EPF00000196:EE_|AS8PR08MB10003:EE_ X-MS-Office365-Filtering-Correlation-Id: b1cfe3ff-eb77-4d95-c25f-08dc18cdd9ee x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Yv0C4n8qw/QsPV4GvzTQpzBXb8gWCBJM8RjVUHqXXoeALjMWqgb1e+pbzEJoyA0d0i+SWvwJ5xDPGSAhihR6vbPUxfBCd+rWnJUkinlz4QX5EHv6NRgkDcGHEk6x1UQOSYWwMv8ELV4Kwiod14nockeIZRFGjyHNBuwhGAJdNsk5U1CsdxPWRUmZ4iAvhNiObErETcSjIK5kqJHvpgYZ7j/+vYctfSMFMmBGhhmQ6phdnVKxtrimcBs+yrW676zrn0t0SmgvKu/GW5bnzQgnm/EVTgsPmqYQHRKi2nb9Drpkhe+lw/lz6WLIXhMstMdt83NORVo7Hk7asC5Vb585YsFPcQtNnZB0+mBSuT2B2Z0OsuPfhhbDdq/SArPWF7v/Gh4d6nPOZYtZdC4qiGFgYG7NUpeJF9XIzUEUk98rwsMgyJtmswnnhF3ud7VxX7n4XfeBXJAnM8MF3ZxWxzSqKqjk0G/DNsirM4POtoEON2vS6YdOR6c4uaqOEcb4oJA1VU/PkCjl9a0XBfpC3M/1R08BSkLQDTQ+eHgC33lrKp8TeXvrrAvge+bLGvYwOp6KJV4Xw39qeXz+u1Zm4ZPYFRLpLZT+vLyeBRs+yglnCn8= 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:(13230031)(136003)(39860400002)(376002)(396003)(366004)(346002)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(26005)(83380400001)(6512007)(44144004)(86362001)(36756003)(2616005)(6506007)(8936002)(8676002)(4326008)(44832011)(235185007)(5660300002)(33964004)(66476007)(66946007)(66556008)(54906003)(316002)(38100700002)(6916009)(41300700001)(966005)(478600001)(2906002)(6486002)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6392 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-Transport-CrossTenantHeadersStripped: AMS0EPF00000196.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 76cbc2d5-08a1-4d43-6623-08dc18cdd46a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oZbqRBPZKR2bWaphyA3KxT5I6U35qy/bWWl3DAIpCLj8AM7Kk6+2xV2eVwaW90E9ubYQdG09oLk1fE2fMyqqEZ4no+k589+dzxSDrBkggMhNaWPabbwPo0oghvJhj5fDuptO7DzeN3KlcnM+Xu7W8LLnthL+HzlVc89V2kdR2ICGZmdBq5NT2m/R6edVYyFVZa9eVhRflBKduiWBNzwQFSkK4CFvYQfANybpucLGiy+mmwp32etIlQ6YWoSrrren7aQyrSOf9MDWHiVQWGzQVA2glQi73cna2RcAGs5muQVapXxJygzaHrDhoHIF/3+Sbw3XuKkKl5SDQ9xVTrBfc/X3wG7KNQxn93t4lSlekRTP6LM3xBZx+mN/MJU06iTDN5QSwgCiBeUCnUSbSA7XmICIlnCaHvCAxH3rC2B7ojrmjbM04bU9q/6Up2kBhfK1cjZ68vtN0UtRhQ4DSHe+gXejYWfMQsAM2DxrRRhpvTKj7Y+i2mM2QyAYYd/XDXYz3Lb4tNWrNjbHHS4tkYI3Fa0Yo50vf/8rSaZMfo0iNPLhFbQU4YGZ3uDiLAVcnJAVN/+tcU7C1v0L9cyiBRJICjTqYr4qZo1kqVVFfl+9/7v0w1X6KREiJX4+lkiv0TI3lu1NJYOtzogefzE49+qJ74jG55Hy4FJdw8QNTsSSPNwGArsqpnb4D/1Y23d8VjI7qjAXkWxM8C1oEISualN9pX9uYj6wzUqM+wsjTNDAohexl8lwQB8Noza6aIO9Ei4IrJfkxglFqcHnj3pQ8E7JxQ== 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:(13230031)(4636009)(136003)(39860400002)(396003)(376002)(346002)(230922051799003)(64100799003)(186009)(82310400011)(451199024)(1800799012)(40470700004)(36840700001)(46966006)(40460700003)(40480700001)(36860700001)(44144004)(33964004)(336012)(26005)(6512007)(2616005)(6506007)(86362001)(36756003)(81166007)(82740400003)(356005)(8676002)(44832011)(41300700001)(966005)(4326008)(6486002)(478600001)(2906002)(235185007)(47076005)(83380400001)(5660300002)(8936002)(316002)(70206006)(70586007)(54906003)(6916009)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 09:05:58.2652 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1cfe3ff-eb77-4d95-c25f-08dc18cdd9ee 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: AMS0EPF00000196.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10003 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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+patchwork=sourceware.org@gcc.gnu.org As the PR shows, we were missing code to update debug uses in the load/store pair fusion pass. This patch fixes that. Note that this patch depends on the following patch to create new uses in RTL-SSA, submitted as part of the fixes for PR113070: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642919.html The patch tries to give a complete treatment of the debug uses that will be affected by the changes we make, and in particular makes an effort to preserve debug info where possible, e.g. when re-ordering an update of a base register by a constant over a debug use of that register. When re-ordering loads over a debug use of a transfer register, we reset the debug insn. Likewise when re-ordering stores over debug uses of mem. While doing this I noticed that try_promote_writeback used a strange choice of move_range for the pair insn, in that it chose the previous nondebug insn instead of the insn itself. Since the insn is being changed, these move ranges are equivalent (at least in terms of nondebug insn placement as far as RTL-SSA is concerned), but I think it is more natural to choose the pair insn itself. This is needed to avoid incorrectly updating some debug uses. Notes on testing: - The series was bootstrapped/regtested on top of the fixes for PR113070 and PR113356. It seemed to make more sense to test with correct use/def info, and as mentioned above, this patch depends on one of the PR113070 patches. - I also ran the testsuite with -g -funroll-loops -mearly-ldp-fusion -mlate-ldp-fusion to try and flush out more issues, and worked through some examples where writeback updates were triggered to make sure it was doing the right thing. - The patches also survived an LTO+PGO bootstrap with --enable-languages=all (with the passes enabled). Bootstrapped/regtested as a series on aarch64-linux-gnu (with/without the pass enabled). OK for trunk? Thanks, Alex gcc/ChangeLog: PR target/113089 * config/aarch64/aarch64-ldp-fusion.cc (reset_debug_use): New. (fixup_debug_use): New. (fixup_debug_uses_trailing_add): New. (fixup_debug_uses): New. Use it ... (ldp_bb_info::fuse_pair): ... here. (try_promote_writeback): Call fixup_debug_uses_trailing_add to fix up debug uses of the base register that are affected by folding in the trailing add insn. gcc/testsuite/ChangeLog: PR target/113089 * gcc.c-torture/compile/pr113089.c: New test. --- gcc/config/aarch64/aarch64-ldp-fusion.cc | 332 +++++++++++++++++- .../gcc.c-torture/compile/pr113089.c | 26 ++ 2 files changed, 351 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr113089.c diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index 4d7fd72c6b1..fd0278e7acf 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -1342,6 +1342,309 @@ ldp_bb_info::track_tombstone (int uid) gcc_unreachable (); // Bit should have changed. } +// Reset the debug insn containing USE (the debug insn has been +// optimized away). +static void +reset_debug_use (use_info *use) +{ + auto use_insn = use->insn (); + auto use_rtl = use_insn->rtl (); + insn_change change (use_insn); + change.new_uses = {}; + INSN_VAR_LOCATION_LOC (use_rtl) = gen_rtx_UNKNOWN_VAR_LOC (); + crtl->ssa->change_insn (change); +} + +// USE is a debug use that needs updating because DEF (a def of the same +// register) is being re-ordered over it. If BASE is non-null, then DEF +// is an update of the register BASE by a constant, given by WB_OFFSET, +// and we can preserve debug info by accounting for the change in side +// effects. +static void +fixup_debug_use (obstack_watermark &attempt, + use_info *use, + def_info *def, + rtx base, + poly_int64 wb_offset) +{ + auto use_insn = use->insn (); + if (base) + { + auto use_rtl = use_insn->rtl (); + insn_change change (use_insn); + + gcc_checking_assert (REG_P (base) && use->regno () == REGNO (base)); + change.new_uses = check_remove_regno_access (attempt, + change.new_uses, + use->regno ()); + + // The effect of the writeback is to add WB_OFFSET to BASE. If + // we're re-ordering DEF below USE, then we update USE by adding + // WB_OFFSET to it. Otherwise, if we're re-ordering DEF above + // USE, we update USE by undoing the effect of the writeback + // (subtracting WB_OFFSET). + use_info *new_use; + if (*def->insn () > *use_insn) + { + // We now need USE_INSN to consume DEF. Create a new use of DEF. + // + // N.B. this means until we call change_insns for the main change + // group we will temporarily have a debug use consuming a def that + // comes after it, but RTL-SSA doesn't currently support updating + // debug insns as part of the main change group (together with + // nondebug changes), so we will have to live with this update + // leaving the IR being temporarily inconsistent. It seems to + // work out OK once the main change group is applied. + wb_offset *= -1; + new_use = crtl->ssa->create_use (attempt, + use_insn, + as_a (def)); + } + else + new_use = find_access (def->insn ()->uses (), use->regno ()); + + change.new_uses = insert_access (attempt, new_use, change.new_uses); + + if (dump_file) + { + const char *dir = (*def->insn () < *use_insn) ? "down" : "up"; + pretty_printer pp; + pp_string (&pp, "["); + pp_access (&pp, use, 0); + pp_string (&pp, "]"); + pp_string (&pp, " due to wb def "); + pp_string (&pp, "["); + pp_access (&pp, def, 0); + pp_string (&pp, "]"); + fprintf (dump_file, + " i%d: fix up debug use %s re-ordered %s, " + "sub r%u -> r%u + ", + use_insn->uid (), pp_formatted_text (&pp), + dir, REGNO (base), REGNO (base)); + print_dec (wb_offset, dump_file); + fprintf (dump_file, "\n"); + } + + insn_propagation prop (use_rtl, base, + plus_constant (GET_MODE (base), base, wb_offset)); + if (prop.apply_to_pattern (&INSN_VAR_LOCATION_LOC (use_rtl))) + crtl->ssa->change_insn (change); + else + { + if (dump_file) + fprintf (dump_file, " i%d: RTL substitution failed (%s)" + ", resetting debug insn", use_insn->uid (), + prop.failure_reason); + reset_debug_use (use); + } + } + else + { + if (dump_file) + { + pretty_printer pp; + pp_string (&pp, "["); + pp_access (&pp, use, 0); + pp_string (&pp, "] due to re-ordered load def ["); + pp_access (&pp, def, 0); + pp_string (&pp, "]"); + fprintf (dump_file, " i%d: resetting debug use %s\n", + use_insn->uid (), pp_formatted_text (&pp)); + } + reset_debug_use (use); + } +} + +// Update debug uses when folding in a trailing add insn to form a +// writeback pair. +// +// ATTEMPT is used to allocate RTL-SSA temporaries for the changes, +// the final pair is placed immediately after PAIR_DST, TRAILING_ADD +// is a trailing add insn which is being folded into the pair to make it +// use writeback addressing, and WRITEBACK_EFFECT is the pattern for +// TRAILING_ADD. +static void +fixup_debug_uses_trailing_add (obstack_watermark &attempt, + insn_info *pair_dst, + insn_info *trailing_add, + rtx writeback_effect) +{ + rtx base = SET_DEST (writeback_effect); + + poly_int64 wb_offset; + rtx base2 = strip_offset (SET_SRC (writeback_effect), &wb_offset); + gcc_checking_assert (rtx_equal_p (base, base2)); + + auto defs = trailing_add->defs (); + gcc_checking_assert (defs.size () == 1); + def_info *def = defs[0]; + + if (auto set = safe_dyn_cast (def->prev_def ())) + for (auto use : set->debug_insn_uses ()) + if (*use->insn () > *pair_dst) + // DEF is getting re-ordered above USE, fix up USE accordingly. + fixup_debug_use (attempt, use, def, base, wb_offset); +} + +// Called from fuse_pair, fixes up any debug uses that will be affected +// by the changes. +// +// ATTEMPT is the obstack watermark used to allocate RTL-SSA temporaries for +// the changes, INSNS gives the candidate insns: at this point the use/def +// information should still be as on entry to fuse_pair, but the patterns may +// have changed, hence we pass ORIG_RTL which contains the original patterns +// for the candidate insns. +// +// The final pair will be placed immediately after PAIR_DST, LOAD_P is true if +// it is a load pair, bit I of WRITEBACK is set if INSNS[I] originally had +// writeback, and WRITEBACK_EFFECT is an rtx describing the overall update to +// the base register in the final pair (if any). BASE_REGNO gives the register +// number of the base register used in the final pair. +static void +fixup_debug_uses (obstack_watermark &attempt, + insn_info *insns[2], + rtx orig_rtl[2], + insn_info *pair_dst, + insn_info *trailing_add, + bool load_p, + int writeback, + rtx writeback_effect, + unsigned base_regno) +{ + // USE is a debug use that needs updating because DEF (a def of the + // resource) is being re-ordered over it. If WRITEBACK_PAT is non-NULL, + // then it gives the original RTL pattern for DEF's insn, and DEF is a + // writeback update of the base register. + // + // This simply unpacks WRITEBACK_PAT if needed and calls fixup_debug_use. + auto update_debug_use = [&](use_info *use, def_info *def, + rtx writeback_pat) + { + poly_int64 offset = 0; + rtx base = NULL_RTX; + if (writeback_pat) + { + rtx mem = XEXP (writeback_pat, load_p); + gcc_checking_assert (GET_RTX_CLASS (GET_CODE (XEXP (mem, 0))) + == RTX_AUTOINC); + + base = ldp_strip_offset (mem, &offset); + gcc_checking_assert (REG_P (base) && REGNO (base) == base_regno); + } + fixup_debug_use (attempt, use, def, base, offset); + }; + + // Reset any debug uses of mem over which we re-ordered a store. + // + // It would be nice to try and preserve debug info here, but it seems that + // would require doing alias analysis to see if the store aliases with the + // debug use, which seems a little extravagant just to preserve debug info. + if (!load_p) + { + auto def = memory_access (insns[0]->defs ()); + auto last_def = memory_access (insns[1]->defs ()); + for (; def != last_def; def = def->next_def ()) + if (auto set = dyn_cast (def)) + for (auto use : set->debug_insn_uses ()) + { + if (dump_file) + fprintf (dump_file, " i%d: resetting debug use of mem\n", + use->insn ()->uid ()); + reset_debug_use (use); + } + } + + // Now let's take care of register uses, starting with debug uses + // attached to defs from our first insn. + for (auto def : insns[0]->defs ()) + { + auto set = dyn_cast (def); + if (!set || set->is_mem () || !set->first_debug_insn_use ()) + continue; + + def_info *defs[2] = { + def, + find_access (insns[1]->defs (), def->regno ()) + }; + + rtx writeback_pats[2] = {}; + if (def->regno () == base_regno) + for (int i = 0; i < 2; i++) + if (defs[i] && (writeback & (1 << i))) + writeback_pats[i] = orig_rtl[i]; + + // Now that we've characterized the defs involved, go through the + // debug uses and determine how to update them (if needed). + for (auto use : set->debug_insn_uses ()) + { + if (*pair_dst < *use->insn () && defs[1]) + // We're re-ordering defs[1] above a previous use of the + // same resource. + update_debug_use (use, defs[1], writeback_pats[1]); + else if (*pair_dst >= *use->insn ()) + // We're re-ordering defs[0] below its use. + update_debug_use (use, defs[0], writeback_pats[0]); + } + } + + // Now let's look at registers which are def'd by the second insn + // but not by the first insn, there may still be debug uses of a + // previous def which can be affected by moving the second insn up. + for (auto def : insns[1]->defs ()) + { + // This should be M log N where N is the number of defs in + // insns[0] and M is the number of defs in insns[1]. + if (def->is_mem () || find_access (insns[0]->defs (), def->regno ())) + continue; + + auto prev_set = safe_dyn_cast (def->prev_def ()); + if (!prev_set) + continue; + + rtx writeback_pat = NULL_RTX; + if (def->regno () == base_regno && (writeback & 2)) + writeback_pat = orig_rtl[1]; + + // We have a def in insns[1] which isn't def'd by the first insn. + // Look to the previous def and see if it has any debug uses. + for (auto use : prev_set->debug_insn_uses ()) + if (*pair_dst < *use->insn ()) + // We're ordering DEF above a previous use of the same register. + update_debug_use (use, def, writeback_pat); + } + + if ((writeback & 2) && !writeback_effect) + { + // If the second insn initially had writeback but the final + // pair does not, then there may be trailing debug uses of the + // second writeback def which need re-parenting: do that. + auto def = find_access (insns[1]->defs (), base_regno); + gcc_assert (def); + for (auto use : as_a (def)->debug_insn_uses ()) + { + insn_change change (use->insn ()); + change.new_uses = check_remove_regno_access (attempt, + change.new_uses, + base_regno); + auto new_use = find_access (insns[0]->uses (), base_regno); + + // N.B. insns must have already shared a common base due to writeback. + gcc_assert (new_use); + + if (dump_file) + fprintf (dump_file, + " i%d: cancelling wb, re-parenting trailing debug use\n", + use->insn ()->uid ()); + + change.new_uses = insert_access (attempt, new_use, change.new_uses); + crtl->ssa->change_insn (change); + } + } + else if (trailing_add) + fixup_debug_uses_trailing_add (attempt, pair_dst, trailing_add, + writeback_effect); +} + // Try and actually fuse the pair given by insns I1 and I2. // // Here we've done enough analysis to know this is safe, we only @@ -1378,6 +1681,9 @@ ldp_bb_info::fuse_pair (bool load_p, insn_info *first = (*i1 < *i2) ? i1 : i2; insn_info *second = (first == i1) ? i2 : i1; + insn_info *pair_dst = move_range.singleton (); + gcc_assert (pair_dst); + insn_info *insns[2] = { first, second }; auto_vec changes; @@ -1388,6 +1694,13 @@ ldp_bb_info::fuse_pair (bool load_p, PATTERN (second->rtl ()) }; + // Make copies of the patterns as we might need to refer to the original RTL + // later, for example when updating debug uses (which is after we've updated + // one or both of the patterns in the candidate insns). + rtx orig_rtl[2]; + for (int i = 0; i < 2; i++) + orig_rtl[i] = copy_rtx (pats[i]); + use_array input_uses[2] = { first->uses (), second->uses () }; def_array input_defs[2] = { first->defs (), second->defs () }; @@ -1604,9 +1917,7 @@ ldp_bb_info::fuse_pair (bool load_p, using Action = stp_change_builder::action; insn_info *store_to_change = try_repurpose_store (first, second, move_range); - insn_info *stp_dest = move_range.singleton (); - gcc_assert (stp_dest); - stp_change_builder builder (insns, store_to_change, stp_dest); + stp_change_builder builder (insns, store_to_change, pair_dst); insn_change *change; set_info *new_set = nullptr; for (; !builder.done (); builder.advance ()) @@ -1677,7 +1988,7 @@ ldp_bb_info::fuse_pair (bool load_p, fprintf (dump_file, " stp: changing i%d to use mem from new stp " "(after i%d)\n", - action.insn->uid (), stp_dest->uid ()); + action.insn->uid (), pair_dst->uid ()); change->new_uses = drop_memory_access (change->new_uses); gcc_assert (new_set); auto new_use = crtl->ssa->create_use (attempt, action.insn, @@ -1741,6 +2052,11 @@ ldp_bb_info::fuse_pair (bool load_p, gcc_assert (crtl->ssa->verify_insn_changes (changes)); + // Fix up any debug uses that will be affected by the changes. + if (MAY_HAVE_DEBUG_INSNS) + fixup_debug_uses (attempt, insns, orig_rtl, pair_dst, trailing_add, + load_p, writeback, writeback_effect, base_regno); + confirm_change_group (); crtl->ssa->change_insns (changes); @@ -2807,7 +3123,7 @@ try_promote_writeback (insn_info *insn) rtx wb_effect = NULL_RTX; def_info *add_def; - const insn_range_info pair_range (insn->prev_nondebug_insn ()); + const insn_range_info pair_range (insn); insn_info *insns[2] = { nullptr, insn }; insn_info *trailing_add = find_trailing_add (insns, pair_range, 0, &wb_effect, &add_def, base_def, offset, @@ -2830,14 +3146,16 @@ try_promote_writeback (insn_info *insn) pair_change.new_defs); gcc_assert (pair_change.new_defs.is_valid ()); - pair_change.move_range = insn_range_info (insn->prev_nondebug_insn ()); - auto is_changing = insn_is_changing (changes); for (unsigned i = 0; i < ARRAY_SIZE (changes); i++) gcc_assert (rtl_ssa::restrict_movement_ignoring (*changes[i], is_changing)); gcc_assert (rtl_ssa::recog_ignoring (attempt, pair_change, is_changing)); gcc_assert (crtl->ssa->verify_insn_changes (changes)); + + if (MAY_HAVE_DEBUG_INSNS) + fixup_debug_uses_trailing_add (attempt, insn, trailing_add, wb_effect); + confirm_change_group (); crtl->ssa->change_insns (changes); } diff --git a/gcc/testsuite/gcc.c-torture/compile/pr113089.c b/gcc/testsuite/gcc.c-torture/compile/pr113089.c new file mode 100644 index 00000000000..70c71f23f1c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr113089.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-g -funroll-loops" } */ + +typedef unsigned short uint16; + +void intrapred_chroma_plane(uint16 ***mb_preds, int* max_imgpel_values, int crx, int cry, int px) { + for (int uv = 0; uv < 2; uv++) { + uint16 **mb_pred = mb_preds[uv + 1]; + uint16 **predU2 = &mb_pred[px - 2]; + uint16 *upPred = &mb_pred[px][px]; + int max_imgpel_value = max_imgpel_values[uv]; + + int ih = upPred[crx - 1]; + for (int i = 0; i < crx*3; ++i) + ih += upPred[crx*3]; + + int iv = (mb_pred[cry - 1][px+1]); + for (int i = 0; i < cry - 1; ++i) { + iv += (i + 1) * (*(mb_preds[uv][0]) - *(*predU2--)); + } + + for (int j = 0; j < cry; ++j) + for (int i = 0; i < crx; ++i) + mb_pred[j][i] = (uint16) (max_imgpel_value * ((i * ih + iv))); + } +}