* fwprop: fix REG_DEAD notes rendered incorrect
@ 2011-10-27 13:32 Alexandre Oliva
2011-10-27 14:58 ` Eric Botcazou
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Oliva @ 2011-10-27 13:32 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]
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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fwprop-update-dead-notes-pr50826.patch --]
[-- Type: text/x-diff, Size: 1438 bytes --]
for gcc/ChangeLog
from Alexandre Oliva <aoliva@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 = ®_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);
[-- Attachment #3: Type: text/plain, Size: 257 bytes --]
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fwprop: fix REG_DEAD notes rendered incorrect
2011-10-27 13:32 fwprop: fix REG_DEAD notes rendered incorrect Alexandre Oliva
@ 2011-10-27 14:58 ` Eric Botcazou
2011-10-27 16:46 ` Alexandre Oliva
0 siblings, 1 reply; 3+ messages in thread
From: Eric Botcazou @ 2011-10-27 14:58 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc-patches
> 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.
This isn't necessarily a bug, i.e. passes aren't required to maintain REG_DEAD
and REG_UNUSED notes up-to-date (another example is PR rtl-opt/48773). Instead
passes consuming these notes have to invoke df_note_add_problem on entry.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fwprop: fix REG_DEAD notes rendered incorrect
2011-10-27 14:58 ` Eric Botcazou
@ 2011-10-27 16:46 ` Alexandre Oliva
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2011-10-27 16:46 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
On Oct 27, 2011, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> 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.
> This isn't necessarily a bug, i.e. passes aren't required to maintain
> REG_DEAD and REG_UNUSED notes up-to-date (another example is PR
> rtl-opt/48773). Instead passes consuming these notes have to invoke
> df_note_add_problem on entry.
It looked confusing, and it wasn't hard to fix, but, ok, patch
withdrawn.
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-27 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-27 13:32 fwprop: fix REG_DEAD notes rendered incorrect Alexandre Oliva
2011-10-27 14:58 ` Eric Botcazou
2011-10-27 16:46 ` Alexandre Oliva
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).