From patchwork Sat Jan 13 15:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 84045 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 969FC3858418 for ; Sat, 13 Jan 2024 15:45:58 +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-vi1eur04on2085.outbound.protection.outlook.com [40.107.8.85]) by sourceware.org (Postfix) with ESMTPS id 4EA513858C29 for ; Sat, 13 Jan 2024 15:45:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4EA513858C29 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 4EA513858C29 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.8.85 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705160734; cv=pass; b=FmPwVUJ8S2oSyrTNqIhuhI0tXYTipD2MAl2Kk09OwlQ2y51fhEmTfQrs1bSZGrRZ7e+LkQzAhZHk+LibyD3XC/yZRGhVY7HLAKqjGNo7d+mVf+CZ89AylkxoRWty3fiiEx/hLzYisG0v7hVcO2TIopvjtduVnnKDVnHz4Imf/kY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1705160734; c=relaxed/simple; bh=ZVix3B6UeyBuojOMU07eFSrUcx4EQc/VY+6MXo0UOgU=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=wMscTqmHkCR9939/6tjB3fh0umzs4wY9EJI5xVCzl3UbaNhsSHYhZLEipKyvcm15n03tJ2y1D8EmlOawZ1/b1suDfHMLbpVzy0HmH3PZ3pBgFP7+Smy43xWPTsI6dSPjihrxwCQX/CYG5sTfJ+BTR7gdAi0yE6ohe1tfFBil53g= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=FsPI94/xqiZHphpE/BcL6mfUukJoOBpXPA8q8na7gKHmjsYgqHnOaCyRo6DWA5V26jG/pcFzUhjd3TnCx81jqASqVMqnJL9vZVzFWJwMA/8Y6x6FzN7CnaQ8rob9r6eDhmFoFW73rZVL/jq42rRjq3VFZK+KF0Ss7isxzyrjXWX+qOVA/9xorgGEi51gWQziIYqIjQJ01QX14o6ZP7dXnGLoK/HCbnYKEM1bhMsjjouNvo85f9q3pKwDuH0XYp+B+747tN/UiM6o2MoNhulqMgrQtKU67KjeM84zitsP2a7h7cByM4dvAztrmsyXOTs5k/2ec79Wd3jqNpo/rlKiyw== 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=Ffnkxrkl862jiy8xABWl6Odrq+oKbWfUPuZ/e1jqY6I=; b=ha8CdW2gMqoEfQ4W5Ct4WK5w5443GNqWQjcAqO0jGWzx5J09Mfghu7P9TZz29CujG1CCj4zF72ATUuLZKvmD1xxhFMSYWrOob6Tf3cryXy5xtGSPwVaa4SEIniMCowwAaSQQMR42liTGY0wFuQBc6spwh/lypJa+7DbDdSK6Chp92Q/OB9FQDDGlK7zF19wCEHwoa3o1+O1wSv/Zsxi0zJQVfKprK65fYM1lDp0S9s5GxmF4YKyt24JEbI3nNZpfo0zlO1igrRPKaOv9R/d3Zibd/b1Ut27H6OaKBABoai2yCmzSfT6E1fkUcWfRjGX6ywPaioO4Jd8pmnE+fIPc9A== 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=Ffnkxrkl862jiy8xABWl6Odrq+oKbWfUPuZ/e1jqY6I=; b=goKSjM18fedbBfsJclF4W7GL4fecQpJeqHB4dZJC/Yn9+xFTqDpqLT1MLnyw3JA1qmcP5nnTj8Ho+0/2TsusSRLs2gmiezfi1G2Q8kdun8zJmeC7SD0XTJaO6oN8fKO5htsDvDf7MahmbUzsvuzGB6RYJ277c9jxISXU2fKhKA4= Received: from AM6PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:20b:f0::27) by AM8PR08MB6372.eurprd08.prod.outlook.com (2603:10a6:20b:369::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23; Sat, 13 Jan 2024 15:45:26 +0000 Received: from AM3PEPF00009BA0.eurprd04.prod.outlook.com (2603:10a6:20b:f0:cafe::80) by AM6PR04CA0050.outlook.office365.com (2603:10a6:20b:f0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.21 via Frontend Transport; Sat, 13 Jan 2024 15:45:26 +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 AM3PEPF00009BA0.mail.protection.outlook.com (10.167.16.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.14 via Frontend Transport; Sat, 13 Jan 2024 15:45:26 +0000 Received: ("Tessian outbound 31df1b57f90c:v228"); Sat, 13 Jan 2024 15:45:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 457cdd9b36aeeb40 X-CR-MTA-TID: 64aa7808 Received: from cccf462281f0.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 31E1F29E-4ABB-4861-9BDC-A7DE3564C25E.1; Sat, 13 Jan 2024 15:45:19 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cccf462281f0.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 13 Jan 2024 15:45:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VIEHX1LmItkLF4QQ71S0NOtyY7Kc+hKZ5tXf/nWRqWwDP+HZYRFuzwP/iA59+MuqJDhVnVRd4gjKxcUdcXkX9c/Z32M68tb+dC59VjfDH7vXcpYvRI99S5+KtMbg/DvN0T8pCwG3D7MMLwkaTcUiqVpc4k5Hl05DKLigDtzn18BIczfGjyBM96YTYjg2hll2Ly6YzRO6iDvEtwMLOgbQSVRCGCo5wrqBD6YX7Ytj8QUbn4ts9y16duTr3Exb1hwevOQY56QSU8mqtqKMGUwWm+cFyMxw8phRWgExYQw8+TKNi8noMSzvowuQBy6pEpWwE5W5s3BtYfMxlaKHZRGvOQ== 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=Ffnkxrkl862jiy8xABWl6Odrq+oKbWfUPuZ/e1jqY6I=; b=ZxyR4DylHMIYx5uz7DdQ1K913xWFyb2lBW0ctqGExJihP1ZrYevEZJD1JQgkwKmLUl7YfAD3j4rvy/OAl9qAmXevPevL3Yb4A31xBebxYd+U5O3oFIymYD5ZT438a3crTHQJeAnlI7RBRRZ4OKcYnQsAIljWzWUKhYvxmLeF2JtaAKS6gM3lunDs4O0XfPlP6HeGigKgaQEdKSFLAKUYtR4xjiZ6sWn+DM9S5/VnIeXb8nuJm7eaYYmyRS12aankEtIiT54TbrgRWHVrBJpKgEPizpz3E24EMmorkDoKJ5cGJUFohgIehsJwtFTlXYk+FrGYPBoie7+XBizRDWaDWQ== 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=Ffnkxrkl862jiy8xABWl6Odrq+oKbWfUPuZ/e1jqY6I=; b=goKSjM18fedbBfsJclF4W7GL4fecQpJeqHB4dZJC/Yn9+xFTqDpqLT1MLnyw3JA1qmcP5nnTj8Ho+0/2TsusSRLs2gmiezfi1G2Q8kdun8zJmeC7SD0XTJaO6oN8fKO5htsDvDf7MahmbUzsvuzGB6RYJ277c9jxISXU2fKhKA4= 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 DB9PR08MB8484.eurprd08.prod.outlook.com (2603:10a6:10:3d4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23; Sat, 13 Jan 2024 15:45:16 +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.7181.015; Sat, 13 Jan 2024 15:45:16 +0000 Date: Sat, 13 Jan 2024 15:45:12 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford , Kyrylo Tkachov , Richard Earnshaw Subject: [PATCH 3/4] rtl-ssa: Ensure new defs get inserted [PR113070] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P123CA0119.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::16) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|DB9PR08MB8484:EE_|AM3PEPF00009BA0:EE_|AM8PR08MB6372:EE_ X-MS-Office365-Filtering-Correlation-Id: c94c74de-1fd9-4b70-a99c-08dc144ea97d 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: JF86OLjn+rXONQgdcAT+D1/x2H/4ekBCrCft3M0kQstqMfEfeWvCmvwFe5CSMfugUKZWl8ST2sCxEpWdYptOWfRnMoI5kPbLowitlsGCev44B6uERAn675Ok7gBE9/bmFWtdYQfRT576AYc+vk8h3x6huRFm4FTUaQZozS7ohSDphA1OTOINbAC0hvPuYBj+tRQ2JT5sCzKfDh0kORaqTGZB9sTlHQ/O28EAIoV7HnvZOwhyuC0u8sg4vVDrtk1II0EYOp3uNG4OrxSw6pmFZLWFD/RECshwmInQ1YsQabWr8XYnvnobgLmO7C58mqh3JbJqKDFGNWIHuiH9tu9rMn1YYCucuEIRd9WP5Lgvu+IzTaJx2GnVEXNfAFa39VQW3R3ak8OSjEoidGjVYww0LnTZCNylA4qq1r5GJkisImhJExX1gVvSXLjxcu4zDv2Z2m0G0Mcctn14cvs7jcDSXUeChiVksAdogI6TPT96tLHNbywS+oiFIzzfZ4o++ihwXAXbhJrOPISY1bbHU6SatA9HwBPyplCdc9SVey3mzs9nDmqan/CqfLXZlPJXtffPBIN4tpMnYFpYWLLtu/1nGWy6yFUQ4u0GgcIw1z1nMJM0Sw0vkIKtexGmE0I/WfbS 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)(396003)(366004)(376002)(346002)(136003)(39860400002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(86362001)(38100700002)(26005)(2616005)(36756003)(83380400001)(6512007)(6506007)(6666004)(316002)(6486002)(33964004)(44144004)(66946007)(54906003)(66556008)(66476007)(6916009)(2906002)(235185007)(44832011)(8676002)(5660300002)(4326008)(478600001)(8936002)(41300700001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8484 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: AM3PEPF00009BA0.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 96eeff1a-7840-4036-55c1-08dc144ea3c4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zuLwdCOw1W2R0SrZc2ppRCl4aeoTDWPUBjmTy7Hy4uHP5P8Nc/Z8RGFmkF4rxd1lc8X83xYLo2dZSY49xNVt30GcK94hCs9H/ZuXY6b/AZqRGC2TrKOWPpjD1PxmrYiFxGafFI7Y0vz6fwzs46SudrbuIXKfMNqwMJKstHxuYMyxitX7ltmMnMOkUCDlNMh5vsDM7xFTxO/XmZgYuOiAtyflddb8kgs0gUepZr5WlXX6G3anmAW5ICJSgtPwyCONDwNcz1Hl2Tz6I4GcOK0FMZNK9KnvBxfFlOrZ1nfRBPVaxcp+8GvwJbdwO0RfpR5SeCExeqFZTYbv4dIpwSj/QvTJ0ctyI4YsRelSZ215jt7w9l9lgIYD/Q40bWdJg9rUbDGG7r8kB/DEK2nY2GQ/flSncptYzYXGgJgpIko3B/AVcaESCtbh+isRuh6nbQ7mKTkQHLarDWZO1LnKWbtPAI2ccVLqX1VRJB4UYIv6B8cd3ipHEtm0XF9namDpz6cAa6xRV6q9Wi1i9YvKB+mVLRu+4NsAxY3+Q/oa1lSIkX3C0wxtY39Xu728Xo7OGGXJAFwFptA6XViIB2y6OrY379KLQmZFCFDq1nBaCswyAipMooPT+bL9gnHBwIv1cvBAZ73jr3uOhXCxbpDFrtxhO1AVjkxjRkLlaTWlliWAzZ889e08MGDLY6MXiuoQiPyxqENXz7h3GBj5Wfs6T3QYawg2tQPUcu0vnpdf2v4yIqxU/5j8j9IjVZpM5pmoCcLd1Ld0UwWEyKP1lygoZ22SwA== 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)(346002)(39860400002)(376002)(396003)(136003)(230922051799003)(1800799012)(451199024)(82310400011)(64100799003)(186009)(36840700001)(40470700004)(46966006)(356005)(81166007)(82740400003)(36756003)(40460700003)(40480700001)(86362001)(336012)(26005)(83380400001)(36860700001)(41300700001)(6512007)(70206006)(54906003)(70586007)(316002)(44144004)(33964004)(6666004)(2616005)(6506007)(47076005)(478600001)(6916009)(6486002)(2906002)(5660300002)(44832011)(4326008)(235185007)(8936002)(8676002)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2024 15:45:26.2732 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c94c74de-1fd9-4b70-a99c-08dc144ea97d 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: AM3PEPF00009BA0.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6372 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 In r14-5820-ga49befbd2c783e751dc2110b544fe540eb7e33eb I added support to RTL-SSA for inserting new insns, which included support for users creating new defs. However, I missed that apply_changes_to_insn needed updating to ensure that the new defs actually got inserted into the main def chain. This meant that when the aarch64 ldp/stp pass inserted a new stp insn, the stp would just get skipped over during subsequent alias analysis, as its def never got inserted into the memory def chain. This (unsurprisingly) led to wrong code. This patch fixes the issue by ensuring new user-created defs get inserted. I would have preferred to have used a flag internal to the defs instead of a separate data structure to keep track of them, but since machine_mode increased to 16 bits we're already at 64 bits in access_info, and we can't really reuse m_is_temp as the logic in finalize_new_accesses requires it to get cleared. Bootstrapped/regtested as a series on aarch64-linux-gnu, OK for trunk? Thanks, Alex gcc/ChangeLog: PR target/113070 * rtl-ssa.h: Include hash-set.h. * rtl-ssa/changes.cc (function_info::finalize_new_accesses): Add new_sets parameter and use it to keep track of new user-created sets. (function_info::apply_changes_to_insn): Also call add_def on new sets. (function_info::change_insns): Add hash_set to keep track of new user-created defs. Plumb it through. * rtl-ssa/functions.h: Add hash_set parameter to finalize_new_accesses and apply_changes_to_insn. --- gcc/rtl-ssa.h | 1 + gcc/rtl-ssa/changes.cc | 28 +++++++++++++++++++++------- gcc/rtl-ssa/functions.h | 6 ++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gcc/rtl-ssa.h b/gcc/rtl-ssa.h index f0cf656f5ac..17337639ae8 100644 --- a/gcc/rtl-ssa.h +++ b/gcc/rtl-ssa.h @@ -50,6 +50,7 @@ #include "mux-utils.h" #include "rtlanal.h" #include "cfgbuild.h" +#include "hash-set.h" // Provides the global crtl->ssa. #include "memmodel.h" diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc index ce51d6ccd8d..6119ec3535b 100644 --- a/gcc/rtl-ssa/changes.cc +++ b/gcc/rtl-ssa/changes.cc @@ -429,7 +429,8 @@ update_insn_in_place (insn_change &change) // POS gives the final position of INSN, which hasn't yet been moved into // place. void -function_info::finalize_new_accesses (insn_change &change, insn_info *pos) +function_info::finalize_new_accesses (insn_change &change, insn_info *pos, + hash_set &new_sets) { insn_info *insn = change.insn (); @@ -465,6 +466,12 @@ function_info::finalize_new_accesses (insn_change &change, insn_info *pos) // later in case we see a second write to the same resource. def_info *perm_def = allocate (change.insn (), def->resource ()); + + // Keep track of the new set so we remember to add it to the + // def chain later. + if (new_sets.add (perm_def)) + gcc_unreachable (); // We shouldn't see duplicates here. + def->set_last_def (perm_def); def = perm_def; } @@ -647,7 +654,8 @@ function_info::finalize_new_accesses (insn_change &change, insn_info *pos) // Copy information from CHANGE to its underlying insn_info, given that // the insn_info has already been placed appropriately. void -function_info::apply_changes_to_insn (insn_change &change) +function_info::apply_changes_to_insn (insn_change &change, + hash_set &new_sets) { insn_info *insn = change.insn (); if (change.is_deletion ()) @@ -659,10 +667,11 @@ function_info::apply_changes_to_insn (insn_change &change) // Copy the cost. insn->set_cost (change.new_cost); - // Add all clobbers. Sets and call clobbers never move relative to - // other definitions, so are OK as-is. + // Add all clobbers and newly-created sets. Existing sets and call + // clobbers never move relative to other definitions, so are OK as-is. for (def_info *def : change.new_defs) - if (is_a (def) && !def->is_call_clobber ()) + if ((is_a (def) && !def->is_call_clobber ()) + || (is_a (def) && new_sets.contains (def))) add_def (def); // Add all uses, now that their position is final. @@ -793,6 +802,10 @@ function_info::change_insns (array_slice changes) placeholders[i] = placeholder; } + // We need to keep track of newly-added sets as these need adding to + // the def chain later. + hash_set new_sets; + // Finalize the new list of accesses for each change. Don't install them yet, // so that we still have access to the old lists below. // @@ -806,7 +819,8 @@ function_info::change_insns (array_slice changes) insn_info *placeholder = placeholders[i]; if (!change.is_deletion ()) finalize_new_accesses (change, - placeholder ? placeholder : change.insn ()); + placeholder ? placeholder : change.insn (), + new_sets); } // Remove all definitions that are no longer needed. After the above, @@ -861,7 +875,7 @@ function_info::change_insns (array_slice changes) // Apply the changes to the underlying insn_infos. for (insn_change *change : changes) - apply_changes_to_insn (*change); + apply_changes_to_insn (*change, new_sets); // Now that the insns and accesses are up to date, add any REG_UNUSED notes. for (insn_change *change : changes) diff --git a/gcc/rtl-ssa/functions.h b/gcc/rtl-ssa/functions.h index 962180e27d6..4573453d896 100644 --- a/gcc/rtl-ssa/functions.h +++ b/gcc/rtl-ssa/functions.h @@ -299,8 +299,10 @@ private: void process_uses_of_deleted_def (set_info *); insn_info *add_placeholder_after (insn_info *); void possibly_queue_changes (insn_change &); - void finalize_new_accesses (insn_change &, insn_info *); - void apply_changes_to_insn (insn_change &); + void finalize_new_accesses (insn_change &, insn_info *, + hash_set &); + void apply_changes_to_insn (insn_change &, + hash_set &); void init_function_data (); void calculate_potential_phi_regs (build_info &);