]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-dse (max_stmt_uid): Removed.
authorKenneth Zadeck <zadeck@naturalbridge.com>
Fri, 16 May 2008 13:38:13 +0000 (09:38 -0400)
committerDiego Novillo <dnovillo@gcc.gnu.org>
Fri, 16 May 2008 13:38:13 +0000 (09:38 -0400)
2008-05-16  Kenneth Zadeck <zadeck@naturalbridge.com>

* tree-ssa-dse (max_stmt_uid): Removed.
(get_stmt_uid, dse_possible_dead_store_p, dse_optimize_stmt,
tree_ssa_dse): Encapsulate all uses of stmt_ann->uid.
* tree-ssa-sccvn.c (compare_ops, init_scc_vn): Ditto.
* function.h (cfun.last_stmt_uid): New field.
* tree-flow-inline.h (set_gimple_stmt_uid, gimple_stmt_uid,
gimple_stmt_max_uid, set_gimple_stmt_max_uid,
inc_gimple_stmt_max_uid): New functions.
* tree-dfa.c (renumber_gimple_stmt_uids): New function.
(create_stmt_ann): Initialize the ann->uid field.
* tree-ssa-pre.c (compute_avail): Encapsulate the stmt_ann->uid
with new calls.
* tree-flow.h (renumber_gimple_stmt_uids): New function.

From-SVN: r135419

gcc/ChangeLog
gcc/function.h
gcc/tree-dfa.c
gcc/tree-flow-inline.h
gcc/tree-flow.h
gcc/tree-ssa-dse.c
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c

index 50eb528a9e97e77e51b6af35b16637de09575110..9208cc6888feff96dc3239b56a812a1f190ab119 100644 (file)
@@ -1,3 +1,19 @@
+2008-05-16  Kenneth Zadeck <zadeck@naturalbridge.com>
+
+       * tree-ssa-dse (max_stmt_uid): Removed.
+       (get_stmt_uid, dse_possible_dead_store_p, dse_optimize_stmt, 
+       tree_ssa_dse): Encapsulate all uses of stmt_ann->uid.
+       * tree-ssa-sccvn.c (compare_ops, init_scc_vn): Ditto.
+       * function.h (cfun.last_stmt_uid): New field.
+       * tree-flow-inline.h (set_gimple_stmt_uid, gimple_stmt_uid,
+       gimple_stmt_max_uid, set_gimple_stmt_max_uid, 
+       inc_gimple_stmt_max_uid): New functions.
+       * tree-dfa.c (renumber_gimple_stmt_uids): New function.
+       (create_stmt_ann): Initialize the ann->uid field.
+       * tree-ssa-pre.c (compute_avail): Encapsulate the stmt_ann->uid
+       with new calls.
+       * tree-flow.h (renumber_gimple_stmt_uids): New function.
+
 2008-05-16  Nathan Froyd  <froydnj@codesourcery.com>
 
        * tree-flow.h (init_empty_tree_cfg_for_function): Declare.
@@ -26,7 +42,7 @@
        * config/bfin/bfin.c (bfin_discover_loops): Delete empty loops.
 
        From Jie Zhang  <jie.zhang@analog.com>
-        * config/bfin/t-bfin-elf (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
+       * config/bfin/t-bfin-elf (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
        MULTILIB_MATCHES, MULTILIB_EXCEPTIONS): Remove mcpu=bf532-0.3,
        mcpu=bf561-none and mcpu=bf561-0.2.
        * config/bfin/t-bfin-uclinux (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
index fcfd3b65f430bebb43427a7408e1ce0c57cfed7b..424cdf7054c754f41187ecb80e71f5d88249d622 100644 (file)
@@ -465,6 +465,9 @@ struct function GTY(())
   /* Used types hash table.  */
   htab_t GTY ((param_is (union tree_node))) used_types_hash;
 
+  /* Last statement uid.  */
+  int last_stmt_uid;
+
   /* Line number of the end of the function.  */
   location_t function_end_locus;
 
index f9784411e411fda7b51891e02eec6a5c817947a4..0a8f88de2975304b2345594d612ef0830f2f3253 100644 (file)
@@ -85,13 +85,30 @@ find_referenced_vars (void)
 {
   basic_block bb;
   block_stmt_iterator si;
+  tree phi;
 
   FOR_EACH_BB (bb)
-    for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
-      {
-       tree *stmt_p = bsi_stmt_ptr (si);
-       walk_tree (stmt_p, find_vars_r, NULL, NULL);
-      }
+    {
+      for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
+       {
+         tree *stmt_p = bsi_stmt_ptr (si);
+         walk_tree (stmt_p, find_vars_r, NULL, NULL);
+       }
+
+      for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
+       {
+         int len = PHI_NUM_ARGS (phi);
+         int i;
+
+         walk_tree (&phi, find_vars_r, NULL, NULL);
+
+         for (i = 0; i < len; i++)
+           {
+             tree arg = PHI_ARG_DEF (phi, i);
+             walk_tree (&arg, find_vars_r, NULL, NULL);
+           }
+       }
+    }
 
   return 0;
 }
@@ -110,8 +127,8 @@ struct gimple_opt_pass pass_referenced_vars =
   PROP_gimple_leh | PROP_cfg,          /* properties_required */
   PROP_referenced_vars,                        /* properties_provided */
   0,                                   /* properties_destroyed */
-  0,                                   /* todo_flags_start */
-  0                                     /* todo_flags_finish */
+  TODO_dump_func,                      /* todo_flags_start */
+  TODO_dump_func                        /* todo_flags_finish */
  }
 };
 
@@ -194,11 +211,37 @@ create_stmt_ann (tree t)
   /* Since we just created the annotation, mark the statement modified.  */
   ann->modified = true;
 
+  ann->uid = inc_gimple_stmt_max_uid (cfun);
   t->base.ann = (tree_ann_t) ann;
 
   return ann;
 }
 
+/* Renumber all of the gimple stmt uids.  */
+
+void 
+renumber_gimple_stmt_uids (void)
+{
+  basic_block bb;
+
+  set_gimple_stmt_max_uid (cfun, 0);
+  FOR_ALL_BB (bb)
+    {
+      block_stmt_iterator bsi;
+      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
+       {
+         tree stmt = bsi_stmt (bsi);
+         /* If the stmt has an annotation, then overwrite it, if not,
+            the process of getting it will set the number
+            properly.  */
+         if (has_stmt_ann (stmt))
+           set_gimple_stmt_uid (stmt, inc_gimple_stmt_max_uid (cfun));
+         else
+           get_stmt_ann (stmt);
+       }
+    }
+}
+
 /* Create a new annotation for a tree T.  */
 
 tree_ann_common_t
@@ -572,9 +615,14 @@ collect_dfa_stats_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
 static tree
 find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
 {
+  /* If we are reading the lto info back in, we need to rescan the
+     referenced vars.  */
+  if (TREE_CODE (*tp) == SSA_NAME)
+    add_referenced_var (SSA_NAME_VAR (*tp));
+
   /* If T is a regular variable that the optimizers are interested
      in, add it to the list of variables.  */
-  if (SSA_VAR_P (*tp))
+  else if (SSA_VAR_P (*tp))
     add_referenced_var (*tp);
 
   /* Type, _DECL and constant nodes have no interesting children.
index 9e8edc6bed1a666abaff0aeab854926268056ff9..a41ee9ac2eb0c6b884c4ee19b76c03865429a3fc 100644 (file)
@@ -278,6 +278,41 @@ get_stmt_ann (tree stmt)
   return (ann) ? ann : create_stmt_ann (stmt);
 }
 
+/* Set the uid of all non phi function statements.  */
+static inline void
+set_gimple_stmt_uid (tree stmt, unsigned int uid)
+{
+  get_stmt_ann (stmt)->uid = uid;
+}
+
+/* Get the uid of all non phi function statements.  */
+static inline unsigned int
+gimple_stmt_uid (tree stmt)
+{
+  return get_stmt_ann (stmt)->uid;
+}
+
+/* Get the number of the next statement uid to be allocated.  */
+static inline unsigned int
+gimple_stmt_max_uid (struct function *fn)
+{
+  return fn->last_stmt_uid;
+}
+
+/* Set the number of the next statement uid to be allocated.  */
+static inline void
+set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
+{
+  fn->last_stmt_uid = maxid;
+}
+
+/* Set the number of the next statement uid to be allocated.  */
+static inline unsigned int
+inc_gimple_stmt_max_uid (struct function *fn)
+{
+  return fn->last_stmt_uid++;
+}
+
 /* Return the annotation type for annotation ANN.  */
 static inline enum tree_ann_type
 ann_type (tree_ann_t ann)
index 019cb7ba09c6c504e0bb39d0c1738e42d2037620..bd1f87ab396a232752d03f69d507bee56360885b 100644 (file)
@@ -485,9 +485,11 @@ struct stmt_ann_d GTY(())
   /* Set of variables that have had their address taken in the statement.  */
   bitmap addresses_taken;
 
-  /* Unique identifier for this statement.  These ID's are to be created
-     by each pass on an as-needed basis in any order convenient for the
-     pass which needs statement UIDs.  */
+  /* Unique identifier for this statement.  These ID's are to be
+     created by each pass on an as-needed basis in any order
+     convenient for the pass which needs statement UIDs.  This field
+     should only be accessed thru set_gimple_stmt_uid and
+     gimple_stmt_uid functions.  */
   unsigned int uid;
 
   /* Nonzero if the statement references memory (at least one of its
@@ -779,6 +781,7 @@ extern tree gimplify_build2 (block_stmt_iterator *, enum tree_code,
 extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
                             tree, tree, tree, tree);
 extern void init_empty_tree_cfg (void);
+extern void init_empty_tree_cfg_for_function (struct function *);
 extern void fold_cond_expr_cond (void);
 extern void make_abnormal_goto_edges (basic_block, bool);
 extern void replace_uses_by (tree, tree);
@@ -801,6 +804,7 @@ extern const char *op_symbol_code (enum tree_code);
 extern var_ann_t create_var_ann (tree);
 extern function_ann_t create_function_ann (tree);
 extern stmt_ann_t create_stmt_ann (tree);
+extern void renumber_gimple_stmt_uids (void);
 extern tree_ann_common_t create_tree_common_ann (tree);
 extern void dump_dfa_stats (FILE *);
 extern void debug_dfa_stats (void);
@@ -893,13 +897,13 @@ DEF_VEC_ALLOC_O(edge_var_map, heap);
 /* A vector of var maps.  */
 typedef VEC(edge_var_map, heap) *edge_var_map_vector;
 
+extern void init_tree_ssa (struct function *);
 extern void redirect_edge_var_map_add (edge, tree, tree);
 extern void redirect_edge_var_map_clear (edge);
 extern void redirect_edge_var_map_dup (edge, edge);
 extern edge_var_map_vector redirect_edge_var_map_vector (edge);
 extern void redirect_edge_var_map_destroy (void);
 
-extern void init_tree_ssa (struct function *);
 extern edge ssa_redirect_edge (edge, basic_block);
 extern void flush_pending_stmts (edge);
 extern bool tree_ssa_useless_type_conversion (tree);
index a4e507c3224c4a5ad106af754a173b4a0d8c260b..f6f76d5b7c5d41b58881b98df2add4cfa99e622d 100644 (file)
@@ -101,19 +101,15 @@ static void dse_record_phis (struct dom_walk_data *, basic_block);
 static void dse_finalize_block (struct dom_walk_data *, basic_block);
 static void record_voperand_set (bitmap, bitmap *, unsigned int);
 
-static unsigned max_stmt_uid;  /* Maximal uid of a statement.  Uids to phi
-                                  nodes are assigned using the versions of
-                                  ssa names they define.  */
-
 /* Returns uid of statement STMT.  */
 
 static unsigned
 get_stmt_uid (tree stmt)
 {
   if (TREE_CODE (stmt) == PHI_NODE)
-    return SSA_NAME_VERSION (PHI_RESULT (stmt)) + max_stmt_uid;
+    return SSA_NAME_VERSION (PHI_RESULT (stmt)) + gimple_stmt_max_uid (cfun);
 
-  return stmt_ann (stmt)->uid;
+  return gimple_stmt_uid (stmt);
 }
 
 /* Set bit UID in bitmaps GLOBAL and *LOCAL, creating *LOCAL as needed.  */
@@ -288,7 +284,6 @@ dse_possible_dead_store_p (tree stmt,
   vuse_vec_p vv;
   tree defvar = NULL_TREE, temp;
   tree prev_defvar = NULL_TREE;
-  stmt_ann_t ann = stmt_ann (stmt);
 
   /* We want to verify that each virtual definition in STMT has
      precisely one use and that all the virtual definitions are
@@ -364,7 +359,7 @@ dse_possible_dead_store_p (tree stmt,
 
   if (fail)
     {
-      record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+      record_voperand_set (dse_gd->stores, &bd->stores, gimple_stmt_uid (stmt));
       return false;
     }
 
@@ -435,7 +430,7 @@ dse_optimize_stmt (struct dom_walk_data *walk_data,
              memory location.  */
           if (!get_kill_of_stmt_lhs (stmt, &first_use_p, &use_p, &use_stmt))
             {
-              record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+              record_voperand_set (dse_gd->stores, &bd->stores, gimple_stmt_uid (stmt));
               return;
             }
         }
@@ -505,7 +500,7 @@ dse_optimize_stmt (struct dom_walk_data *walk_data,
          release_defs (stmt);
        }
 
-      record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+      record_voperand_set (dse_gd->stores, &bd->stores, gimple_stmt_uid (stmt));
     }
 }
 
@@ -556,18 +551,8 @@ tree_ssa_dse (void)
 {
   struct dom_walk_data walk_data;
   struct dse_global_data dse_gd;
-  basic_block bb;
 
-  /* Create a UID for each statement in the function.  Ordering of the
-     UIDs is not important for this pass.  */
-  max_stmt_uid = 0;
-  FOR_EACH_BB (bb)
-    {
-      block_stmt_iterator bsi;
-
-      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-       stmt_ann (bsi_stmt (bsi))->uid = max_stmt_uid++;
-    }
+  renumber_gimple_stmt_uids ();
 
   /* We might consider making this a property of each pass so that it
      can be [re]computed on an as-needed basis.  Particularly since
index 4119467964322d4c373cea79330f3a9a238c289b..e52b02ab026bd307d4febd938316fd4aae9f7047 100644 (file)
@@ -3171,7 +3171,6 @@ insert_fake_stores (void)
              new_tree = build_gimple_modify_stmt (NULL_TREE, lhs);
              new_lhs = make_ssa_name (storetemp, new_tree);
              GIMPLE_STMT_OPERAND (new_tree, 0) = new_lhs;
-
              create_ssa_artificial_load_stmt (new_tree, stmt, false);
 
              NECESSARY (new_tree) = 0;
@@ -3494,7 +3493,7 @@ compute_avail (void)
          stmt = bsi_stmt (bsi);
          ann = stmt_ann (stmt);
 
-         ann->uid = stmt_uid++;
+         set_gimple_stmt_uid (stmt, stmt_uid++);
 
          /* For regular value numbering, we are only interested in
             assignments of the form X_i = EXPR, where EXPR represents
index e8eb437d3e607ca97a259b338ee1aa8573c844f8..0b20a4ebc72a23e45f333bdbd329a78ca10ecda3 100644 (file)
@@ -1890,7 +1890,7 @@ compare_ops (const void *pa, const void *pb)
        return -1;
       else if (TREE_CODE (opstmtb) == PHI_NODE)
        return 1;
-      return stmt_ann (opstmta)->uid - stmt_ann (opstmtb)->uid;
+      return gimple_stmt_uid (opstmta) - gimple_stmt_uid (opstmtb);
     }
   return rpo_numbers[bba->index] - rpo_numbers[bbb->index];
 }
@@ -2089,8 +2089,6 @@ init_scc_vn (void)
   size_t i;
   int j;
   int *rpo_numbers_temp;
-  basic_block bb;
-  size_t id = 0;
 
   calculate_dominance_info (CDI_DOMINATORS);
   sccstack = NULL;
@@ -2131,15 +2129,7 @@ init_scc_vn (void)
        }
     }
 
-  FOR_ALL_BB (bb)
-    {
-      block_stmt_iterator bsi;
-      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-       {
-         tree stmt = bsi_stmt (bsi);
-         stmt_ann (stmt)->uid = id++;
-       }
-    }
+  renumber_gimple_stmt_uids ();
 
   /* Create the valid and optimistic value numbering tables.  */
   valid_info = XCNEW (struct vn_tables_s);