OSDN Git Service

* tracer.c (rest_of_handle_tracer): We already cleaned
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-copyrename.c
index 494e3a5..2311afa 100644 (file)
@@ -16,8 +16,8 @@ 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, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include "config.h"
 #include "system.h"
@@ -39,8 +39,6 @@ Boston, MA 02111-1307, USA.  */
 #include "tree-pass.h"
 #include "langhooks.h"
 
-extern void rename_ssa_copies (void);
-
 /* The following routines implement the SSA copy renaming phase.
 
    This optimization looks for copies between 2 SSA_NAMES, either through a
@@ -123,8 +121,8 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
   gcc_assert (TREE_CODE (var1) == SSA_NAME);
   gcc_assert (TREE_CODE (var2) == SSA_NAME);
 
-  register_ssa_partition (map, var1, false);
-  register_ssa_partition (map, var2, true);
+  register_ssa_partition (map, var1);
+  register_ssa_partition (map, var2);
 
   p1 = partition_find (map->var_partition, SSA_NAME_VERSION (var1));
   p2 = partition_find (map->var_partition, SSA_NAME_VERSION (var2));
@@ -146,19 +144,6 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
   root1 = SSA_NAME_VAR (rep1);
   root2 = SSA_NAME_VAR (rep2);
 
-  if (DECL_HARD_REGISTER (root1) || DECL_HARD_REGISTER (root2))
-    {
-      if (debug)
-        {
-         if (DECL_HARD_REGISTER (root1))
-           print_generic_expr (debug, var1, TDF_SLIM);
-         else
-           print_generic_expr (debug, var2, TDF_SLIM);
-         fprintf (debug, " is a hardware register.  No Coalescing.\n");
-       }
-      return;
-    }
-
   ann1 = var_ann (root1);
   ann2 = var_ann (root2);
 
@@ -169,6 +154,16 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
       return;
     }
 
+  /* Don't coalesce if one of the variables occurs in an abnormal PHI.  */
+  abnorm = (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rep1)
+           || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rep2));
+  if (abnorm)
+    {
+      if (debug)
+       fprintf (debug, " : Abnormal PHI barrier.  No coalesce.\n");
+      return;
+    }
+
   /* Partitions already have the same root, simply merge them.  */
   if (root1 == root2)
     {
@@ -213,8 +208,9 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
     }
 
   /* Don't coalesce if there are two different memory tags.  */
-  if (ann1->type_mem_tag && ann2->type_mem_tag
-      && ann1->type_mem_tag != ann2->type_mem_tag)
+  if (ann1->symbol_mem_tag
+      && ann2->symbol_mem_tag
+      && ann1->symbol_mem_tag != ann2->symbol_mem_tag)
     {
       if (debug)
        fprintf (debug, " : 2 memory tags. No coalesce.\n");
@@ -223,9 +219,9 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
 
   /* If both values have default defs, we can't coalesce.  If only one has a 
      tag, make sure that variable is the new root partition.  */
-  if (default_def (root1))
+  if (gimple_default_def (cfun, root1))
     {
-      if (default_def (root2))
+      if (gimple_default_def (cfun, root2))
        {
          if (debug)
            fprintf (debug, " : 2 default defs. No coalesce.\n");
@@ -237,7 +233,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
          ign1 = false;
        }
     }
-  else if (default_def (root2))
+  else if (gimple_default_def (cfun, root2))
     {
       ign1 = true;
       ign2 = false;
@@ -251,16 +247,18 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
       return;
     }
 
-  /* Don't coalesce if one of the variables occurs in an abnormal PHI.  */
-  abnorm = (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rep1)
-           || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rep2));
-  if (abnorm)
+  /* Don't coalesce if the aliasing sets of the types are different.  */
+  if (POINTER_TYPE_P (TREE_TYPE (root1))
+      && POINTER_TYPE_P (TREE_TYPE (root2))
+      && get_alias_set (TREE_TYPE (TREE_TYPE (root1)))
+          != get_alias_set (TREE_TYPE (TREE_TYPE (root2))))
     {
       if (debug)
-       fprintf (debug, " : Abnormal PHI barrier.  No coalesce.\n");
+       fprintf (debug, " : 2 different aliasing sets. No coalesce.\n");
       return;
     }
 
+
   /* Merge the two partitions.  */
   p3 = partition_union (map->var_partition, p1, p2);
 
@@ -273,10 +271,10 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
 
   /* Update the various flag widgitry of the current base representative.  */
   ann3 = var_ann (SSA_NAME_VAR (partition_to_var (map, p3)));
-  if (ann1->type_mem_tag)
-    ann3->type_mem_tag = ann1->type_mem_tag;
+  if (ann1->symbol_mem_tag)
+    ann3->symbol_mem_tag = ann1->symbol_mem_tag;
   else
-    ann3->type_mem_tag = ann2->type_mem_tag;
+    ann3->symbol_mem_tag = ann2->symbol_mem_tag;
 
   if (debug)
     {
@@ -294,7 +292,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
    then cause the SSA->normal pass to attempt to coalesce them all to the same 
    variable.  */
 
-void
+static unsigned int
 rename_ssa_copies (void)
 {
   var_map map;
@@ -317,10 +315,10 @@ rename_ssa_copies (void)
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
        {
          stmt = bsi_stmt (bsi); 
-         if (TREE_CODE (stmt) == MODIFY_EXPR)
+         if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
            {
-             tree lhs = TREE_OPERAND (stmt, 0);
-             tree rhs = TREE_OPERAND (stmt, 1);
+             tree lhs = GIMPLE_STMT_OPERAND (stmt, 0);
+             tree rhs = GIMPLE_STMT_OPERAND (stmt, 1);
 
               if (TREE_CODE (lhs) == SSA_NAME && TREE_CODE (rhs) == SSA_NAME)
                copy_rename_partition_coalesce (map, lhs, rhs, debug);
@@ -376,6 +374,7 @@ rename_ssa_copies (void)
     }
 
   delete_var_map (map);
+  return 0;
 }
 
 /* Return true if copy rename is to be performed.  */
@@ -395,7 +394,7 @@ struct tree_opt_pass pass_rename_ssa_copies =
   NULL,                                        /* next */
   0,                                   /* static_pass_number */
   TV_TREE_COPY_RENAME,                 /* tv_id */
-  PROP_cfg | PROP_ssa | PROP_alias,    /* properties_required */
+  PROP_cfg | PROP_ssa,                 /* properties_required */
   0,                                   /* properties_provided */
   0,                                   /* properties_destroyed */
   0,                                   /* todo_flags_start */