[02/23] rtlanal: Remove noop_move_p REG_EQUAL condition

Message ID mpt8sb5ad5m.fsf@arm.com
State New
Headers show
Series
  • Make fwprop use an on-the-side RTL SSA representation
Related show

Commit Message

Hongtao Liu via Gcc-patches Nov. 13, 2020, 8:12 a.m.
noop_move_p currently keeps any instruction that has a REG_EQUAL
note, on the basis that the equality might be useful in future.
But this creates a perverse incentive not to add potentially-useful
REG_EQUAL notes, in case they prevent an instruction from later being
removed as dead.

The condition originates from flow.c:life_analysis_1 and predates
the changes tracked by the current repository (1992).  It probably
made sense when most optimisations were done on RTL rather than FE
trees, but it seems counterproductive now.

gcc/
	* rtlanal.c (noop_move_p): Don't check for REG_EQUAL notes.
---
 gcc/rtlanal.c | 4 ----
 1 file changed, 4 deletions(-)

-- 
2.17.1

Comments

Hongtao Liu via Gcc-patches Nov. 25, 2020, 8 p.m. | #1
On 11/13/20 1:12 AM, Richard Sandiford via Gcc-patches wrote:
> noop_move_p currently keeps any instruction that has a REG_EQUAL

> note, on the basis that the equality might be useful in future.

> But this creates a perverse incentive not to add potentially-useful

> REG_EQUAL notes, in case they prevent an instruction from later being

> removed as dead.

>

> The condition originates from flow.c:life_analysis_1 and predates

> the changes tracked by the current repository (1992).  It probably

> made sense when most optimisations were done on RTL rather than FE

> trees, but it seems counterproductive now.

>

> gcc/

> 	* rtlanal.c (noop_move_p): Don't check for REG_EQUAL notes.

I would  guess this was primarily for the old libcall mechanism where
we'd have a self-copy at the end of the sequence with a REG_EQUAL note
for the expression's natural form.  All that's been broken for a long
time.  So I'm not going to lose any sleep if we want to remove this
little chunk of code.

OK

jeff

Patch

diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 01130a10783..6f521503c39 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -1668,10 +1668,6 @@  noop_move_p (const rtx_insn *insn)
   if (INSN_CODE (insn) == NOOP_MOVE_INSN_CODE)
     return 1;
 
-  /* Insns carrying these notes are useful later on.  */
-  if (find_reg_note (insn, REG_EQUAL, NULL_RTX))
-    return 0;
-
   /* Check the code to be executed for COND_EXEC.  */
   if (GET_CODE (pat) == COND_EXEC)
     pat = COND_EXEC_CODE (pat);