public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: jlaw@ventanamicro.com, gcc-patches@gcc.gnu.org
Cc: Richard Sandiford <richard.sandiford@arm.com>
Subject: [PATCH 2/6] rtl-ssa: Create REG_UNUSED notes after all pending changes
Date: Tue, 24 Oct 2023 11:50:02 +0100	[thread overview]
Message-ID: <20231024105006.3337671-3-richard.sandiford@arm.com> (raw)
In-Reply-To: <20231024105006.3337671-1-richard.sandiford@arm.com>

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<insn_change *> 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.
-- 
2.25.1


  parent reply	other threads:[~2023-10-24 10:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 10:50 [PATCH 0/6] rtl-ssa: Various fixes needed for the late-combine pass Richard Sandiford
2023-10-24 10:50 ` [PATCH 1/6] rtl-ssa: Ensure global registers are live on exit Richard Sandiford
2023-10-24 17:21   ` Jeff Law
2023-10-24 10:50 ` Richard Sandiford [this message]
2023-10-24 17:22   ` [PATCH 2/6] rtl-ssa: Create REG_UNUSED notes after all pending changes Jeff Law
2023-10-24 10:50 ` [PATCH 3/6] rtl-ssa: Fix ICE when deleting memory clobbers Richard Sandiford
2023-10-24 17:24   ` Jeff Law
2023-10-24 10:50 ` [PATCH 4/6] rtl-ssa: Handle artifical uses of deleted defs Richard Sandiford
2023-10-24 17:26   ` Jeff Law
2023-10-24 10:50 ` [PATCH 5/6] rtl-ssa: Calculate dominance frontiers for the exit block Richard Sandiford
2023-10-24 17:28   ` Jeff Law
2023-10-24 10:50 ` [PATCH 6/6] rtl-ssa: Handle call clobbers in more places Richard Sandiford
2023-10-24 17:37   ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231024105006.3337671-3-richard.sandiford@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jlaw@ventanamicro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).