fwprop may propagate a SET_SRC that contains the last use of a REG to a
later point, but it will leave the REG_DEAD note in place, even though
it is no longer correct.  I noticed this while investigating PR50826:
the initialization of the internal_arg_pointer has a REG_DEAD note for
%r29, but even after it is fwpropped, the note remains there.  This
patch fixes this bug.

It also reduces the risk of code divergence in VTA-enabled compilations,
by enabling the simpler test in all_uses_available_at when there are
debug insns between the def and the use.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

for  gcc/ChangeLog
from  Alexandre Oliva  <aol...@redhat.com>

	* fwprop.c (all_uses_available_at): Skip debug insns.
	(try_fwprop_subst): Drop outdated REG_DEAD notes.
	
Index: gcc/fwprop.c
===================================================================
--- gcc/fwprop.c.orig	2011-10-26 06:37:08.154321512 -0200
+++ gcc/fwprop.c	2011-10-26 06:52:44.163150398 -0200
@@ -801,7 +801,7 @@ all_uses_available_at (rtx def_insn, rtx
 
   /* If target_insn comes right after def_insn, which is very common
      for addresses, we can use a quicker test.  */
-  if (NEXT_INSN (def_insn) == target_insn
+  if (next_nondebug_insn (def_insn) == target_insn
       && REG_P (SET_DEST (def_set)))
     {
       rtx def_reg = SET_DEST (def_set);
@@ -1019,6 +1019,22 @@ try_fwprop_subst (df_ref use, rtx *loc, 
 	}
     }
 
+  if (ok)
+    {
+      rtx *link = &REG_NOTES (def_insn);
+
+      while (*link)
+	if (REG_NOTE_KIND (*link) == REG_DEAD
+	    && reg_mentioned_p (XEXP (*link, 0), new_rtx))
+	  /* We could propagate the REG_DEAD note if we knew we're
+	     propagating into what will become a death point.
+	     Considering multiple uses in different BBs, some of which
+	     may be debug uses requiring debug stmts to be introduced,
+	     how about we just let DF take care of it?  */
+	  *link = XEXP (*link, 1);
+	else
+	  link = &XEXP (*link, 1);
+    }
   if ((ok || note) && !CONSTANT_P (new_rtx))
     update_df (insn, note);
 
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Reply via email to