From patchwork Tue Jul 16 14:34:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1961103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4WNhRq6Zybz1xqc for ; Wed, 17 Jul 2024 00:35:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D0B83846423 for ; Tue, 16 Jul 2024 14:35:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id E0FE53861807 for ; Tue, 16 Jul 2024 14:34:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E0FE53861807 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 E0FE53861807 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721140481; cv=none; b=KmLGCDenkJx76WkBbZCRkTvLI54rBNOo4ZSg92tvKFwbjw+97fcafXzca14WNeq5H/Wg95IX6FAnWKDLhrk1VChDyZy8cda7HKfUc/sp4ZpXdaSrB6kYOypX/GY3zDq1Zd+3WXFHcL2CyVT4odMGpt6IalCamHa2nzXU8f4RWTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721140481; c=relaxed/simple; bh=QLwtOoqzrAWljDLKZKf1RMRlPf2E4lcpElZ0RT7/rRg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=H9kajuEnFwliwITv3rTVJYKQHsgb7rrjElwKeMvF6OhFQMlWZeRINN5KGUhFRKyPpi1awdrVd1AQLr/Ie++tuLvp3eupYtbMMj5RKYLKQ202VnCPkok06dFQ87UHbIlaJE8/rDyd8b919nVJHwpN9trcYWadNZ9i+6b/sdWrNSY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B3741063 for ; Tue, 16 Jul 2024 07:35:05 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 56E6F3F762 for ; Tue, 16 Jul 2024 07:34:39 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [pushed] rtl-ssa: Fix removal of order_nodes [PR115929] Date: Tue, 16 Jul 2024 15:34:37 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spam-Status: No, score=-19.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP 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 order_nodes are used to implement ordered comparisons between two insns with the same program point number. remove_insn would remove an order_node from its splay tree, but didn't remove it from the insn. This caused confusion if the insn was later reinserted somewhere else that also needed an order_node. Tested on aarch64-linux-gnu & x86_64-linux-gnu. Pushed as obvious. Richard gcc/ PR rtl-optimization/115929 * rtl-ssa/insns.cc (function_info::remove_insn): Remove an order_node from the instruction as well as from the splay tree. gcc/testsuite/ PR rtl-optimization/115929 * gcc.dg/torture/pr115929-1.c: New test. --- gcc/rtl-ssa/insns.cc | 5 ++- gcc/testsuite/gcc.dg/torture/pr115929-1.c | 45 +++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr115929-1.c diff --git a/gcc/rtl-ssa/insns.cc b/gcc/rtl-ssa/insns.cc index 7e26bfd978f..bc30734df89 100644 --- a/gcc/rtl-ssa/insns.cc +++ b/gcc/rtl-ssa/insns.cc @@ -393,7 +393,10 @@ void function_info::remove_insn (insn_info *insn) { if (insn_info::order_node *order = insn->get_order_node ()) - insn_info::order_splay_tree::remove_node (order); + { + insn_info::order_splay_tree::remove_node (order); + insn->remove_note (order); + } if (auto *note = insn->find_note ()) { diff --git a/gcc/testsuite/gcc.dg/torture/pr115929-1.c b/gcc/testsuite/gcc.dg/torture/pr115929-1.c new file mode 100644 index 00000000000..19b831ab99e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr115929-1.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-fno-gcse -fschedule-insns -fno-guess-branch-probability -fno-tree-fre -fno-tree-ch" } */ + +int printf(const char *, ...); +int a[6], b, c; +char d, l; +struct { + char e; + int f; + int : 8; + long g; + long h; +} i[1][9] = {0}; +unsigned j; +void n(char p) { b = b >> 8 ^ a[b ^ p]; } +int main() { + int k, o; + while (b) { + k = 0; + for (; k < 9; k++) { + b = b ^ a[l]; + n(j); + if (o) + printf(&d); + long m = i[c][k].f; + b = b >> 8 ^ a[l]; + n(m >> 32); + n(m); + if (o) + printf("%d", d); + b = b >> 8 ^ l; + n(2); + n(0); + if (o) + printf(&d); + b = b ^ a[l]; + n(i[c][k].g >> 2); + n(i[c][k].g); + if (o) + printf(&d); + printf("%d", i[c][k].f); + } + } + return 0; +}