From patchwork Tue Oct 24 10:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 157377 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1852929vqx; Tue, 24 Oct 2023 03:51:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoGTAt7Ouu5z/C8TACtCGmD2m1F9fqw9QQdgitVDsaKWNv1qj65/jaFjyt1uWk7h44T5WQ X-Received: by 2002:a05:620a:2991:b0:76f:1f05:e994 with SMTP id r17-20020a05620a299100b0076f1f05e994mr13107639qkp.64.1698144707941; Tue, 24 Oct 2023 03:51:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698144707; cv=pass; d=google.com; s=arc-20160816; b=kF0kH6UcncQthBj2MPVWszzP5X+BalPdr8Lpe9Gy4ijhtSq9BF9fbaFP+78y11cM6i 7f548yosSmtOhk7iGXvkaWeuJQmvTcOhr6By+4jGllPuRNTJy6Em97wesAtkYvog0FmM wH6HT81MdYOgXDLWS27Rf9gSqaj/av9YPAXp6WFyjVs+gwVI50flufiFGdKCK/u1yfvJ +40MCCCKlEfC+DGo6r6+NlFQ8Q99I3eY4PY38BzUhqb9iJx+pYOg2qRmBMV407i6qrMt r30SHVUTjRau9mNn1KOukAh1Nk5P2fFpkebxUA5p/d761FR6Ag/cGlkCiUDx31XiEu5T dYWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=34+NfBEhRRsdWAIn2MEpZzC5sZtXaa4DvAtKY7mCFn0=; fh=WSfZ840Wi6BqtTz8VZjapJ1yCCJ9QRCfxSVxwOS9rLc=; b=MeRStgL4efO8lNPIVYdGwtraLS2xjC3JSxbB4x1P29Eacx0ZmVUlyaNLMVSRoONFhp jTCGU0e71lAey/uE66vqKJdCK7ClWzcmWB7wyCT3eJTk9WKvJFGLz97ytOmaVD6hyUZX DP6lG6O+BFQfdy+pJpPxrA20WKzgnMDMV5RtiaHckn1kmJHQzScJ5AMPyFl2uLKVA+q5 uBaIMHg+dVSRKTlaWRussr6CW+I7dEjUZ4ratOk1OhLVbF7vFy2UawbNXNr1Koxd5jyT SPwgkpy5eZAeLeRLGXzCQmNdpo9iVMCW8BcC6casZ+dzO8nTbTW/v3e/0riFP8xWKJ6f 3B2g== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u4-20020ac858c4000000b004178c9b7d0bsi6874536qta.328.2023.10.24.03.51.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70437385B53E for ; Tue, 24 Oct 2023 10:51:33 +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 D27BE3858D37 for ; Tue, 24 Oct 2023 10:50:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D27BE3858D37 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 D27BE3858D37 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=1698144640; cv=none; b=nMCShQsMYOfW4HySPSGwl6vGb2TFcqjISVslkM58fFAExmHxAdcFkjeL8Q4vL7jDgh8JfRw7hzcVWa2JLc7Zvb0vzbgjnjgUT9XgxEK9D6PcCbG7KqnNZLup5rhkNc/J+WW7XqqyGBz2pLb6ZSFS15oaIUMnsocKwcqDhIVjL40= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698144640; c=relaxed/simple; bh=IV99aYtsb9iovGz+496UfOvEcRK3IkiOsaUfvQA/c8c=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=sCtzJvIxQoqEf6j7nYDobKrIJEfVDb7NqXmGiyQ6YLdyL4I55jeum84dVHxOwYw0PI+kNHXeYb8h17llA+0l7B8iYJyTvrQVKyDOFZS7Gd5zIIL9Pjs2NZS/Pg3epe7lt3Y6Vc/CIPcOWu6tJjF3BPZrL+F+o7hKSoAsIuCFGM4= 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 9A3B01424; Tue, 24 Oct 2023 03:51:16 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0CA353F64C; Tue, 24 Oct 2023 03:50:34 -0700 (PDT) From: Richard Sandiford To: jlaw@ventanamicro.com, gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH 2/6] rtl-ssa: Create REG_UNUSED notes after all pending changes Date: Tue, 24 Oct 2023 11:50:02 +0100 Message-Id: <20231024105006.3337671-3-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231024105006.3337671-1-richard.sandiford@arm.com> References: <20231024105006.3337671-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-24.0 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780633785399780888 X-GMAIL-MSGID: 1780633785399780888 Unlike REG_DEAD notes, REG_UNUSED notes need to be kept free of false positives by all passes. function_info::change_insns does this by removing all REG_UNUSED notes, and then using add_reg_unused_notes to add notes back (or create new ones) where appropriate. The problem was that it called add_reg_unused_notes on the fly while updating each instruction, which meant that the information for later instructions in the change set wasn't up to date. This patch does it in a separate loop instead. gcc/ * rtl-ssa/changes.cc (function_info::apply_changes_to_insn): Remove call to add_reg_unused_notes and instead... (function_info::change_insns): ...use a separate loop here. --- gcc/rtl-ssa/changes.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc index de6222ae736..c73c23c86fb 100644 --- a/gcc/rtl-ssa/changes.cc +++ b/gcc/rtl-ssa/changes.cc @@ -586,8 +586,6 @@ function_info::apply_changes_to_insn (insn_change &change) insn->set_accesses (builder.finish ().begin (), num_defs, num_uses); } - - add_reg_unused_notes (insn); } // Add a temporary placeholder instruction after AFTER. @@ -733,9 +731,14 @@ function_info::change_insns (array_slice changes) } } - // Finally apply the changes to the underlying insn_infos. + // Apply the changes to the underlying insn_infos. for (insn_change *change : changes) apply_changes_to_insn (*change); + + // Now that the insns and accesses are up to date, add any REG_UNUSED notes. + for (insn_change *change : changes) + if (!change->is_deletion ()) + add_reg_unused_notes (change->insn ()); } // See the comment above the declaration.