diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2007-11-09 13:02:25 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-11-09 14:02:25 +0100 |
commit | de266950570fd88e4e205bfb87bcbd7ba89b5c27 (patch) | |
tree | 2787d0ea1d32fb11d9a9124a3793a190bc159486 /gcc | |
parent | 96cdfb52ff5c5ff9c7b73ef81b23fc1e637b925b (diff) | |
download | gcc-de266950570fd88e4e205bfb87bcbd7ba89b5c27.zip gcc-de266950570fd88e4e205bfb87bcbd7ba89b5c27.tar.gz gcc-de266950570fd88e4e205bfb87bcbd7ba89b5c27.tar.bz2 |
re PR rtl-optimization/34012 (Pessimization caused by fwprop)
PR rtl-optimization/34012
* fwprop.c (try_fwprop_subst): Do not replace if the new
SET_SRC has a higher cost than the old one.
* gcc.target/i386/pr34012.c: New test.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r130043
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fwprop.c | 39 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr34012.c | 25 |
4 files changed, 69 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 53c9777..3fac080 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-11-09 Paolo Bonzini <bonzini@gnu.org> + Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/34012 + * fwprop.c (try_fwprop_subst): Do not replace if the new + SET_SRC has a higher cost than the old one. + 2007-11-09 Eric Botcazou <ebotcazou@libertysurf.fr> PR rtl-optimization/33732 diff --git a/gcc/fwprop.c b/gcc/fwprop.c index ff3123f..eecd0a0 100644 --- a/gcc/fwprop.c +++ b/gcc/fwprop.c @@ -675,6 +675,9 @@ try_fwprop_subst (struct df_ref *use, rtx *loc, rtx new, rtx def_insn, bool set_ rtx insn = DF_REF_INSN (use); enum df_ref_type type = DF_REF_TYPE (use); int flags = DF_REF_FLAGS (use); + rtx set = single_set (insn); + int old_cost = rtx_cost (SET_SRC (set), SET); + bool ok; if (dump_file) { @@ -685,11 +688,34 @@ try_fwprop_subst (struct df_ref *use, rtx *loc, rtx new, rtx def_insn, bool set_ fprintf (dump_file, "\n"); } - if (validate_unshare_change (insn, loc, new, false)) + validate_unshare_change (insn, loc, new, true); + if (!verify_changes (0)) + { + if (dump_file) + fprintf (dump_file, "Changes to insn %d not recognized\n", + INSN_UID (insn)); + ok = false; + } + + else if (rtx_cost (SET_SRC (set), SET) > old_cost) + { + if (dump_file) + fprintf (dump_file, "Changes to insn %d not profitable\n", + INSN_UID (insn)); + ok = false; + } + + else { - num_changes++; if (dump_file) fprintf (dump_file, "Changed insn %d\n", INSN_UID (insn)); + ok = true; + } + + if (ok) + { + confirm_change_group (); + num_changes++; df_ref_remove (use); if (!CONSTANT_P (new)) @@ -697,13 +723,10 @@ try_fwprop_subst (struct df_ref *use, rtx *loc, rtx new, rtx def_insn, bool set_ update_df (insn, loc, DF_INSN_USES (def_insn), type, flags); update_df (insn, loc, DF_INSN_EQ_USES (def_insn), type, flags); } - return true; } else { - if (dump_file) - fprintf (dump_file, "Changes to insn %d not recognized\n", - INSN_UID (insn)); + cancel_changes (0); /* Can also record a simplified value in a REG_EQUAL note, making a new one if one does not already exist. */ @@ -724,9 +747,9 @@ try_fwprop_subst (struct df_ref *use, rtx *loc, rtx new, rtx def_insn, bool set_ type, DF_REF_IN_NOTE); } } - - return false; } + + return ok; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5cb97b9..40c3dc0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-11-09 Paolo Bonzini <bonzini@gnu.org> + Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/34012 + * gcc.target/i386/pr34012.c: New test. + 2007-11-09 Richard Guenther <rguenther@suse.de> PR tree-optimization/33604 diff --git a/gcc/testsuite/gcc.target/i386/pr34012.c b/gcc/testsuite/gcc.target/i386/pr34012.c new file mode 100644 index 0000000..00b1240 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr34012.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/34012 */ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2" } */ + +void bar (long int *); +void +foo (void) +{ + long int buf[10]; + buf[0] = 0x0808080808080808; + buf[1] = 0x0808080808080808; + buf[2] = 0x0808080808080808; + buf[3] = 0x0808080808080808; + buf[4] = 0x0808080808080808; + buf[5] = 0x0808080808080808; + buf[6] = 0x0808080808080808; + buf[7] = 0x0808080808080808; + buf[8] = 0x0808080808080808; + buf[9] = 0x0808080808080808; + bar (buf); +} + +/* Check that CSE did its job and fwprop hasn't undone it. */ +/* { dg-final { scan-assembler-times "578721382704613384|0808080808080808" 1 } } */ |