This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR/29840, fwprop chokes on PA
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Dave Anglin <dave dot anglin at nrc dot ca>, Steven Bosscher <stevenb dot gcc at gmail dot com>
- Date: Tue, 19 Dec 2006 16:19:20 +0100
- Subject: [PATCH] PR/29840, fwprop chokes on PA
In some cases, fwprop would forward propagate call-clobbered hard
registers across function calls. This is fixed easily by passing
DF_HARD_REGS to df_init: then dataflow will create fake definitions for
these call clobbered registers, which is enough to fix the testcase in
the PR audit trail. (I don't know PA assembler, but the bad
propagations disappear from the fwprop1 dump).
Note that it is not necessary to block propagations of hard registers
(e.g. based on SMALL_REGISTER_CLASSES) because actually fwprop does not
do this kind of propagation at all: see the beginning of propagate_rtx.
A followup patch could make these two lines of propagate_rtx less
strict:
if (REG_P (new) && REGNO (new) < FIRST_PSEUDO_REGISTER)
return NULL_RTX;
(again, based on CLASS_LIKELY_SPILLED_P, or SMALL_REGISTER_CLASSES) but
this is independent from fixing this PR.
Another fix, merged from dataflow branch, is to skip artificial defs and
uses.
Bootstrapped/regtested on i686-pc-linux-gnu. Ok for mainline?
Paolo
:ADDPATCH middle-end (RTL):
2006-12-19 Paolo Bonzini <bonzini@gnu.org>
PR rtl-optimization/29840
* fwprop.c (forward_propagate_into): Reject artificial uses/defs.
(fwprop_init): Add DF_HARD_REGS to df_init call.
Index: fwprop.c
===================================================================
--- fwprop.c (revision 120045)
+++ fwprop.c (working copy)
@@ -846,6 +860,8 @@ forward_propagate_into (struct df_ref *u
if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE)
return;
+ if (DF_REF_FLAGS (use) & DF_REF_ARTIFICIAL)
+ return;
/* Only consider uses that have a single definition. */
defs = DF_REF_CHAIN (use);
@@ -855,6 +876,8 @@ forward_propagate_into (struct df_ref *u
def = defs->ref;
if (DF_REF_FLAGS (def) & DF_REF_READ_WRITE)
return;
+ if (DF_REF_FLAGS (def) & DF_REF_ARTIFICIAL)
+ return;
/* Do not propagate loop invariant definitions inside the loop if
we are going to unroll. */
@@ -899,7 +922,7 @@ fwprop_init (void)
/* Now set up the dataflow problem (we only want use-def chains) and
put the dataflow solver to work. */
- df = df_init (DF_SUBREGS | DF_EQUIV_NOTES);
+ df = df_init (DF_HARD_REGS | DF_SUBREGS | DF_EQUIV_NOTES);
df_chain_add_problem (df, DF_UD_CHAIN);
df_analyze (df);
df_dump (df, dump_file);