public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4913] rtl-ssa: Create REG_UNUSED notes after all pending changes
@ 2023-10-25  9:40 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2023-10-25  9:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d5e0321c3f423e307f063c51a6e0795d9daa9309

commit r14-4913-gd5e0321c3f423e307f063c51a6e0795d9daa9309
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Wed Oct 25 10:39:50 2023 +0100

    rtl-ssa: Create REG_UNUSED notes after all pending changes
    
    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.

Diff:
---
 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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-25  9:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25  9:40 [gcc r14-4913] rtl-ssa: Create REG_UNUSED notes after all pending changes Richard Sandiford

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).