]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-cfg.c (set_bb_for_stmt): Use PHI_BB.
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
Sat, 11 Sep 2004 20:42:06 +0000 (22:42 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Sat, 11 Sep 2004 20:42:06 +0000 (20:42 +0000)
* tree-cfg.c (set_bb_for_stmt): Use PHI_BB.
* tree-dfa.c (compute_immediate_uses, add_immediate_use,
redirect_immediate_use): Use PHI_DF.
* tree-flow-inline.h (stmt_ann): Abort on phi nodes.
(bb_for_stmt): Use PHI_BB.
(get_immediate_uses): Use PHI_DF.
* tree-ssa-dse.c (max_stmt_uid): New variable.
(get_stmt_uid): New function.
(dse_optimize_stmt, dse_record_phis, tree_ssa_dse): Do not use phi
node annotations.
* tree-ssa-loop-im.c (LIM_DATA): Do not use phi statement annotations.
(max_uid): Renamed to max_stmt_uid.
(get_stmt_uid): New function.
(maybe_queue_var, single_reachable_address, determine_lsm): Do not use
phi node annotations.
* tree-ssa.c (replace_immediate_uses): Do not use phi node annotations.
* tree.h (PHI_BB, PHI_DF): New accessor functions.
(struct tree_phi_node): Add bb and df fields.

From-SVN: r87369

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-dfa.c
gcc/tree-flow-inline.h
gcc/tree-ssa-dse.c
gcc/tree-ssa-loop-im.c
gcc/tree-ssa.c
gcc/tree.h

index 0e371fa6ab463d4d3d2a296a90716b7dfa06afe1..e84d9cd5f27c45de7a259e39caaec594678b6d83 100644 (file)
@@ -1,3 +1,24 @@
+2004-09-11  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+
+       * tree-cfg.c (set_bb_for_stmt): Use PHI_BB.
+       * tree-dfa.c (compute_immediate_uses, add_immediate_use,
+       redirect_immediate_use): Use PHI_DF.
+       * tree-flow-inline.h (stmt_ann): Abort on phi nodes.
+       (bb_for_stmt): Use PHI_BB.
+       (get_immediate_uses): Use PHI_DF.
+       * tree-ssa-dse.c (max_stmt_uid): New variable.
+       (get_stmt_uid): New function.
+       (dse_optimize_stmt, dse_record_phis, tree_ssa_dse): Do not use phi
+       node annotations.
+       * tree-ssa-loop-im.c (LIM_DATA): Do not use phi statement annotations.
+       (max_uid): Renamed to max_stmt_uid.
+       (get_stmt_uid): New function.
+       (maybe_queue_var, single_reachable_address, determine_lsm): Do not use
+       phi node annotations.
+       * tree-ssa.c (replace_immediate_uses): Do not use phi node annotations.
+       * tree.h (PHI_BB, PHI_DF): New accessor functions.
+       (struct tree_phi_node): Add bb and df fields.
+
 2004-09-11  Richard Henderson  <rth@redhat.com>
 
        PR middle-end/17416
index 14f7d1da8bd90c1b5946c9176e2bb8d70a78e49b..8e9e5af64ac4777935ce28db6464e483120a1530 100644 (file)
@@ -2666,7 +2666,9 @@ last_and_only_stmt (basic_block bb)
 void
 set_bb_for_stmt (tree t, basic_block bb)
 {
-  if (TREE_CODE (t) == STATEMENT_LIST)
+  if (TREE_CODE (t) == PHI_NODE)
+    PHI_BB (t) = bb;
+  else if (TREE_CODE (t) == STATEMENT_LIST)
     {
       tree_stmt_iterator i;
       for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
index 3ceb60afd3ba9d0291a163a45e2514371bbe9f04..af6d9eddfc4f47e506a02834ad567d6116d2ae81 100644 (file)
@@ -191,19 +191,31 @@ compute_immediate_uses (int flags, bool (*calc_for)(tree))
 static void
 free_df_for_stmt (tree stmt)
 {
-  stmt_ann_t ann = stmt_ann (stmt);
+  dataflow_t *df;
 
-  if (ann && ann->df)
+  if (TREE_CODE (stmt) == PHI_NODE)
+    df = &PHI_DF (stmt);
+  else
     {
-      /* If we have a varray of immediate uses, then go ahead and release
-        it for re-use.  */
-      if (ann->df->immediate_uses)
-       ggc_free (ann->df->immediate_uses);
-
-      /* Similarly for the main dataflow structure.  */
-      ggc_free (ann->df);
-      ann->df = NULL;
+      stmt_ann_t ann = stmt_ann (stmt);
+
+      if (!ann)
+       return;
+
+      df = &ann->df;
     }
+
+  if (!*df)
+    return;
+      
+  /* If we have a varray of immediate uses, then go ahead and release
+     it for re-use.  */
+  if ((*df)->immediate_uses)
+    ggc_free ((*df)->immediate_uses);
+
+  /* Similarly for the main dataflow structure.  */
+  ggc_free (*df);
+  *df = NULL;
 }
 
 
@@ -302,28 +314,34 @@ compute_immediate_uses_for_stmt (tree stmt, int flags, bool (*calc_for)(tree))
 static void
 add_immediate_use (tree stmt, tree use_stmt)
 {
-  stmt_ann_t ann = get_stmt_ann (stmt);
-  struct dataflow_d *df;
+  struct dataflow_d **df;
+
+  if (TREE_CODE (stmt) == PHI_NODE)
+    df = &PHI_DF (stmt);
+  else
+    {
+      stmt_ann_t ann = get_stmt_ann (stmt);
+      df = &ann->df;
+    }
 
-  df = ann->df;
-  if (df == NULL)
+  if (*df == NULL)
     {
-      df = ann->df = ggc_alloc (sizeof (struct dataflow_d));
-      memset ((void *) df, 0, sizeof (struct dataflow_d));
-      df->uses[0] = use_stmt;
+      *df = ggc_alloc (sizeof (struct dataflow_d));
+      memset ((void *) *df, 0, sizeof (struct dataflow_d));
+      (*df)->uses[0] = use_stmt;
       return;
     }
 
-  if (!df->uses[1])
+  if (!(*df)->uses[1])
     {
-      df->uses[1] = use_stmt;
+      (*df)->uses[1] = use_stmt;
       return;
     }
 
-  if (ann->df->immediate_uses == NULL)
-    VARRAY_TREE_INIT (ann->df->immediate_uses, 4, "immediate_uses");
+  if ((*df)->immediate_uses == NULL)
+    VARRAY_TREE_INIT ((*df)->immediate_uses, 4, "immediate_uses");
 
-  VARRAY_PUSH_TREE (ann->df->immediate_uses, use_stmt);
+  VARRAY_PUSH_TREE ((*df)->immediate_uses, use_stmt);
 }
 
 
@@ -333,7 +351,7 @@ static void
 redirect_immediate_use (tree use, tree old, tree new)
 {
   tree imm_stmt = SSA_NAME_DEF_STMT (use);
-  struct dataflow_d *df = get_stmt_ann (imm_stmt)->df;
+  struct dataflow_d *df = get_immediate_uses (imm_stmt);
   unsigned int num_uses = num_immediate_uses (df);
   unsigned int i;
 
index cd2bf9ec082ee0c4091f275fdeac9a600338112d..61ed11268f7bab5c9388584caf38e49e9c1bf682 100644 (file)
@@ -78,7 +78,12 @@ ann_type (tree_ann_t ann)
 static inline basic_block
 bb_for_stmt (tree t)
 {
-  stmt_ann_t ann = stmt_ann (t);
+  stmt_ann_t ann;
+
+  if (TREE_CODE (t) == PHI_NODE)
+    return PHI_BB (t);
+
+  ann = stmt_ann (t);
   return ann ? ann->bb : NULL;
 }
 
@@ -305,7 +310,12 @@ addresses_taken (tree stmt)
 static dataflow_t
 get_immediate_uses (tree stmt)
 {
-  stmt_ann_t ann = stmt_ann (stmt);
+  stmt_ann_t ann;
+
+  if (TREE_CODE (stmt) == PHI_NODE)
+    return PHI_DF (stmt);
+
+  ann = stmt_ann (stmt);
   return ann ? ann->df : NULL;
 }
 
index 820b2c6378cb0075992fd132e4e1c2481d997b74..4cc136bf2ddc2798bc0f076fdc20851e24e59721 100644 (file)
@@ -98,6 +98,21 @@ static void fix_phi_uses (tree, tree);
 static void fix_stmt_v_may_defs (tree, tree);
 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 stmt_ann (stmt)->uid;
+}
+
 /* Function indicating whether we ought to include information for 'var'
    when calculating immediate uses.  For this pass we only want use
    information for virtual variables.  */
@@ -270,7 +285,7 @@ dse_optimize_stmt (struct dom_walk_data *walk_data,
         same block.  */
       while (num_uses == 1
             && TREE_CODE (use) == PHI_NODE
-            && bitmap_bit_p (dse_gd->stores, stmt_ann (use)->uid))
+            && bitmap_bit_p (dse_gd->stores, get_stmt_uid (use)))
        {
          /* Record the first PHI we skip so that we can fix its
             uses if we find that STMT is a dead store.  */
@@ -287,7 +302,7 @@ dse_optimize_stmt (struct dom_walk_data *walk_data,
       /* If we have precisely one immediate use at this point, then we may
         have found redundant store.  */
       if (num_uses == 1
-         && bitmap_bit_p (dse_gd->stores, stmt_ann (use)->uid)
+         && bitmap_bit_p (dse_gd->stores, get_stmt_uid (use))
          && operand_equal_p (TREE_OPERAND (stmt, 0),
                              TREE_OPERAND (use, 0), 0))
        {
@@ -333,7 +348,7 @@ dse_record_phis (struct dom_walk_data *walk_data, basic_block bb)
     if (need_imm_uses_for (PHI_RESULT (phi)))
       record_voperand_set (dse_gd->stores,
                           &bd->stores,
-                          get_stmt_ann (phi)->uid);
+                          get_stmt_uid (phi));
 }
 
 static void
@@ -356,21 +371,17 @@ tree_ssa_dse (void)
 {
   struct dom_walk_data walk_data;
   struct dse_global_data dse_gd;
-  unsigned int uid = 0;
   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;
-      tree phi;
 
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-       stmt_ann (bsi_stmt (bsi))->uid = uid++;
-
-      for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
-       stmt_ann (phi)->uid = uid++;
+       stmt_ann (bsi_stmt (bsi))->uid = max_stmt_uid++;
     }
 
   /* We might consider making this a property of each pass so that it
index c0d2c00ad9ee0d08389ac95f04457dfe9731ffff..bc606e60a8a8f1f5921a581fc7cdd58a8a2bd878 100644 (file)
@@ -76,7 +76,9 @@ struct lim_aux_data
                                   MAX_LOOP loop.  */
 };
 
-#define LIM_DATA(STMT) ((struct lim_aux_data *) (stmt_ann (STMT)->common.aux))
+#define LIM_DATA(STMT) (TREE_CODE (STMT) == PHI_NODE \
+                       ? NULL \
+                       : (struct lim_aux_data *) (stmt_ann (STMT)->common.aux))
 
 /* Description of a memory reference for store motion.  */
 
@@ -94,9 +96,20 @@ struct mem_ref
    block will be executed.  */
 #define ALWAYS_EXECUTED_IN(BB) ((struct loop *) (BB)->aux)
 
-/* Maximum uid in the statement in the function.  */
+static unsigned max_stmt_uid;  /* Maximal uid of a statement.  Uids to phi
+                                  nodes are assigned using the versions of
+                                  ssa names they define.  */
 
-static unsigned max_uid;
+/* 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 stmt_ann (stmt)->uid;
+}
 
 /* Calls CBCK for each index in memory reference ADDR_P.  There are two
    kinds situations handled; in each of these cases, the memory reference
@@ -805,10 +818,10 @@ maybe_queue_var (tree var, struct loop *loop,
              
   if (!def_bb
       || !flow_bb_inside_loop_p (loop, def_bb)
-      || TEST_BIT (seen, stmt_ann (stmt)->uid))
+      || TEST_BIT (seen, get_stmt_uid (stmt)))
     return;
          
-  SET_BIT (seen, stmt_ann (stmt)->uid);
+  SET_BIT (seen, get_stmt_uid (stmt));
   queue[(*in_queue)++] = stmt;
 }
 
@@ -900,6 +913,7 @@ single_reachable_address (struct loop *loop, tree stmt,
                          struct mem_ref **mem_refs,
                          bool *seen_call_stmt)
 {
+  unsigned max_uid = max_stmt_uid + num_ssa_names;
   tree *queue = xmalloc (sizeof (tree) * max_uid);
   sbitmap seen = sbitmap_alloc (max_uid);
   unsigned in_queue = 1;
@@ -917,7 +931,7 @@ single_reachable_address (struct loop *loop, tree stmt,
   sra_data.common_ref = NULL_TREE;
 
   queue[0] = stmt;
-  SET_BIT (seen, stmt_ann (stmt)->uid);
+  SET_BIT (seen, get_stmt_uid (stmt));
   *seen_call_stmt = false;
 
   while (in_queue)
@@ -975,9 +989,9 @@ single_reachable_address (struct loop *loop, tree stmt,
          if (!flow_bb_inside_loop_p (loop, bb_for_stmt (stmt)))
            continue;
 
-         if (TEST_BIT (seen, stmt_ann (stmt)->uid))
+         if (TEST_BIT (seen, get_stmt_uid (stmt)))
            continue;
-         SET_BIT (seen, stmt_ann (stmt)->uid);
+         SET_BIT (seen, get_stmt_uid (stmt));
 
          queue[in_queue++] = stmt;
        }
@@ -1230,17 +1244,13 @@ determine_lsm (struct loops *loops)
 
   /* Create a UID for each statement in the function.  Ordering of the
      UIDs is not important for this pass.  */
-  max_uid = 0;
+  max_stmt_uid = 0;
   FOR_EACH_BB (bb)
     {
       block_stmt_iterator bsi;
-      tree phi;
 
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-       stmt_ann (bsi_stmt (bsi))->uid = max_uid++;
-
-      for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
-       stmt_ann (phi)->uid = max_uid++;
+       stmt_ann (bsi_stmt (bsi))->uid = max_stmt_uid++;
     }
 
   compute_immediate_uses (TDFA_USE_VOPS, NULL);
index 2da6c99651efffcd2b8ec8088f8f76c017608d51..c8ced3632a2d7dd53fd6b89b3bf22a3e48069c53 100644 (file)
@@ -916,7 +916,6 @@ replace_immediate_uses (tree var, tree repl)
   int i, j, n;
   dataflow_t df;
   tree stmt;
-  stmt_ann_t ann;
   bool mark_new_vars;
   ssa_op_iter iter;
   use_operand_p use_p;
@@ -927,7 +926,6 @@ replace_immediate_uses (tree var, tree repl)
   for (i = 0; i < n; i++)
     {
       stmt = immediate_use (df, i);
-      ann = stmt_ann (stmt);
 
       if (TREE_CODE (stmt) == PHI_NODE)
        {
index 461b86769785332bc715a96c844a6ff4b01e70d9..bdd95aab2a9ec52600dd4041ed933d19646b6a05 100644 (file)
@@ -1293,6 +1293,8 @@ struct tree_ssa_name GTY(())
 #define PHI_ARG_ELT(NODE, I)           PHI_NODE_ELT_CHECK (NODE, I)
 #define PHI_ARG_EDGE(NODE, I)          PHI_NODE_ELT_CHECK (NODE, I).e
 #define PHI_ARG_NONZERO(NODE, I)       PHI_NODE_ELT_CHECK (NODE, I).nonzero
+#define PHI_BB(NODE)                   PHI_NODE_CHECK (NODE)->phi.bb
+#define PHI_DF(NODE)                   PHI_NODE_CHECK (NODE)->phi.df
 
 struct edge_def;
 
@@ -1314,6 +1316,12 @@ struct tree_phi_node GTY(())
      SSA renamer.  */
   int rewritten;
 
+  /* Basic block to that the phi node belongs.  */
+  struct basic_block_def *bb;
+
+  /* Dataflow information.  */
+  struct dataflow_d *df;
+
   struct phi_arg_d GTY ((length ("((tree)&%h)->phi.capacity"))) a[1];
 };
 \f