summaryrefslogtreecommitdiff
path: root/gcc/fwprop.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-11-09 13:02:25 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-11-09 13:02:25 +0000
commit91bd874e0fada88f33f2618061e20804adbd3239 (patch)
tree2787d0ea1d32fb11d9a9124a3793a190bc159486 /gcc/fwprop.c
parent0565d6c88151e7f00949d0d630a2577169c6c0df (diff)
downloadgcc-91bd874e0fada88f33f2618061e20804adbd3239.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130043 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fwprop.c')
-rw-r--r--gcc/fwprop.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index ff3123fe9e3..eecd0a0a5de 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;
}