From patchwork Mon Jul 22 15:45:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1963303 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=8.43.85.97; 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 [8.43.85.97]) (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 4WSPkw2LlZz1yZ7 for ; Tue, 23 Jul 2024 01:46:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F0C43858416 for ; Mon, 22 Jul 2024 15:45:58 +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 237223861000 for ; Mon, 22 Jul 2024 15:45:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 237223861000 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 237223861000 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=1721663137; cv=none; b=a7Di0zgO8kOwy0DiNmy3Jj3n4zwECAiQKN1AYnQp9E+fA9MDZ0VBJlmEBCfb2TGf4MzhszBVR8V8dbNZNpfGmu2PtQNYYQ3JtbADUDq/PwGcLN/WxT4dUh2SiRPLDmJFdDCmyojHFIjsbg14BHk0lgm7/hrbLTY2D/GxCiHIsVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721663137; c=relaxed/simple; bh=/HbPEg1AS5/2hOFFFQQcqO/cpS/exHGpYFo2eZVWmCY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=M8zaKijHes8q5bNzOfOW+4j++vVryWHUxKKf6b/uqZ/1XBKgVUNxRgdFKJE+HNanWwUG3mE+AHYC4EHjwFfmnW6LZYSXFcAd3Q3MeK0T0yFSUHfejp34s6x1p2be6vqxBI0DfNWsOAbexodg/OisAALAp7JH2iz6scmMjn0cYDE= 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 56631FEC for ; Mon, 22 Jul 2024 08:46:01 -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 8072F3F5A1 for ; Mon, 22 Jul 2024 08:45:35 -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: Avoid using a stale splay tree root [PR116009] Date: Mon, 22 Jul 2024 16:45:34 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spam-Status: No, score=-19.3 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 In the fix for PR115928, I'd failed to notice that "root" was used later in the function, so needed to be updated. Boostrapped & regression-tested on aarch64-linux-gnu. Pushed as obvious. Richard gcc/ PR rtl-optimization/116009 * rtl-ssa/accesses.cc (function_info::add_def): Set the root local variable after removing the old clobber group. gcc/testsuite/ PR rtl-optimization/116009 * gcc.c-torture/compile/pr116009.c: New test. --- gcc/rtl-ssa/accesses.cc | 3 ++- .../gcc.c-torture/compile/pr116009.c | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr116009.c diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc index c77a1ff7ea7..0bba8391b00 100644 --- a/gcc/rtl-ssa/accesses.cc +++ b/gcc/rtl-ssa/accesses.cc @@ -946,7 +946,8 @@ function_info::add_def (def_info *def) prev = split_clobber_group (group, insn); next = prev->next_def (); tree.remove_root (); - last->set_splay_root (tree.root ()); + root = tree.root (); + last->set_splay_root (root); } // COMPARISON is < 0 if DEF comes before ROOT or > 0 if DEF comes // after ROOT. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr116009.c b/gcc/testsuite/gcc.c-torture/compile/pr116009.c new file mode 100644 index 00000000000..6a888d450f4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr116009.c @@ -0,0 +1,23 @@ +int tt, tt1; +int y6; +void ff(void); +int ttt; +void g(int var) { + do { + int t1 = var == 45 || var == 3434; + if (tt != 0) + if (t1) + ff(); + if (tt < 0) + break; + if (t1) + ff(); + if (tt < 0) + break; + ff(); + if (tt1) + var = y6; + if (t1) + ff(); + } while(1); +}