OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / fwprop.c
index 3722811..6bc9c67 100644 (file)
@@ -6,7 +6,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,9 +15,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -676,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)
     {
@@ -686,11 +688,35 @@ 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 (DF_REF_TYPE (use) == DF_REF_REG_USE
+          && 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))
@@ -698,13 +724,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.  */
@@ -725,9 +748,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;
 }
 
 
@@ -1000,7 +1023,7 @@ struct tree_opt_pass pass_rtl_fwprop =
   0,                                    /* properties_provided */
   0,                                    /* properties_destroyed */
   0,                                    /* todo_flags_start */
-  TODO_df_finish |
+  TODO_df_finish | TODO_verify_rtl_sharing |
   TODO_dump_func,                       /* todo_flags_finish */
   0                                     /* letter */
 };
@@ -1042,7 +1065,7 @@ struct tree_opt_pass pass_rtl_fwprop_addr =
   0,                                    /* properties_provided */
   0,                                    /* properties_destroyed */
   0,                                    /* todo_flags_start */
-  TODO_df_finish |
+  TODO_df_finish | TODO_verify_rtl_sharing |
   TODO_dump_func,                       /* todo_flags_finish */
   0                                     /* letter */
 };