OSDN Git Service

2009-04-20 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Apr 2009 14:01:52 +0000 (14:01 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Apr 2009 14:01:52 +0000 (14:01 +0000)
* basic-block.h (get_all_dominated_blocks): Declare.
* dominance.c (get_all_dominated_blocks): New function.
* tree-cfg.c (get_all_dominated_blocks): Remove.
(remove_edge_and_dominated_blocks): Adjust.
* tree-ssa-phiprop.c (tree_ssa_phiprop_1): Fold in ...
(tree_ssa_phiprop): ... here.  Use get_all_dominated_blocks
instead of recursing.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146425 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/basic-block.h
gcc/dominance.c
gcc/tree-cfg.c
gcc/tree-ssa-phiprop.c

index a25d3b0..0fb7222 100644 (file)
@@ -1,3 +1,13 @@
+2009-04-20  Richard Guenther  <rguenther@suse.de>
+
+       * basic-block.h (get_all_dominated_blocks): Declare.
+       * dominance.c (get_all_dominated_blocks): New function.
+       * tree-cfg.c (get_all_dominated_blocks): Remove.
+       (remove_edge_and_dominated_blocks): Adjust.
+       * tree-ssa-phiprop.c (tree_ssa_phiprop_1): Fold in ...
+       (tree_ssa_phiprop): ... here.  Use get_all_dominated_blocks
+       instead of recursing.
+
 2009-04-20  Doug Kwan  <dougkwan@google.com>
 
        * cgraph.h (cgraph_node_ptr): New type for vector functions.
index bd741b5..dfde673 100644 (file)
@@ -938,6 +938,8 @@ extern VEC (basic_block, heap) *get_dominated_by (enum cdi_direction, basic_bloc
 extern VEC (basic_block, heap) *get_dominated_by_region (enum cdi_direction,
                                                         basic_block *,
                                                         unsigned);
+extern VEC (basic_block, heap) *get_all_dominated_blocks (enum cdi_direction,
+                                                         basic_block);
 extern void add_to_dominance_info (enum cdi_direction, basic_block);
 extern void delete_from_dominance_info (enum cdi_direction, basic_block);
 basic_block recompute_dominator (enum cdi_direction, basic_block);
index b4dff4c..2cc1414 100644 (file)
@@ -782,6 +782,33 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region,
   return doms;
 }
 
+/* Returns the list of basic blocks including BB dominated by BB, in the
+   direction DIR.  The vector will be sorted in preorder.  */
+
+VEC (basic_block, heap) *
+get_all_dominated_blocks (enum cdi_direction dir, basic_block bb)
+{
+  VEC(basic_block, heap) *bbs = NULL;
+  unsigned i;
+
+  i = 0;
+  VEC_safe_push (basic_block, heap, bbs, bb);
+
+  do
+    {
+      basic_block son;
+
+      bb = VEC_index (basic_block, bbs, i++);
+      for (son = first_dom_son (dir, bb);
+          son;
+          son = next_dom_son (dir, son))
+       VEC_safe_push (basic_block, heap, bbs, son);
+    }
+  while (i < VEC_length (basic_block, bbs));
+
+  return bbs;
+}
+
 /* Redirect all edges pointing to BB to TO.  */
 void
 redirect_immediate_dominators (enum cdi_direction dir, basic_block bb,
index 9c70146..009f9a9 100644 (file)
@@ -6681,20 +6681,6 @@ gimple_purge_dead_abnormal_call_edges (basic_block bb)
   return changed;
 }
 
-/* Stores all basic blocks dominated by BB to DOM_BBS.  */
-
-static void
-get_all_dominated_blocks (basic_block bb, VEC (basic_block, heap) **dom_bbs)
-{
-  basic_block son;
-
-  VEC_safe_push (basic_block, heap, *dom_bbs, bb);
-  for (son = first_dom_son (CDI_DOMINATORS, bb);
-       son;
-       son = next_dom_son (CDI_DOMINATORS, son))
-    get_all_dominated_blocks (son, dom_bbs);
-}
-
 /* Removes edge E and all the blocks dominated by it, and updates dominance
    information.  The IL in E->src needs to be updated separately.
    If dominance info is not available, only the edge E is removed.*/
@@ -6754,7 +6740,7 @@ remove_edge_and_dominated_blocks (edge e)
                    get_immediate_dominator (CDI_DOMINATORS, e->dest)->index);
   else
     {
-      get_all_dominated_blocks (e->dest, &bbs_to_remove);
+      bbs_to_remove = get_all_dominated_blocks (CDI_DOMINATORS, e->dest);
       for (i = 0; VEC_iterate (basic_block, bbs_to_remove, i, bb); i++)
        {
          FOR_EACH_EDGE (f, ei, bb->succs)
index d95b358..f608f1d 100644 (file)
@@ -325,41 +325,34 @@ next:;
   return phi_inserted;
 }
 
-/* Helper walking the dominator tree starting from BB and processing
-   phi nodes with global data PHIVN and N.  */
-
-static bool
-tree_ssa_phiprop_1 (basic_block bb, struct phiprop_d *phivn, size_t n)
-{
-  bool did_something = false; 
-  basic_block son;
-  gimple_stmt_iterator gsi;
-
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-    did_something |= propagate_with_phi (bb, gsi_stmt (gsi), phivn, n);
-
-  for (son = first_dom_son (CDI_DOMINATORS, bb);
-       son;
-       son = next_dom_son (CDI_DOMINATORS, son))
-    did_something |= tree_ssa_phiprop_1 (son, phivn, n);
-
-  return did_something;
-}
-
 /* Main entry for phiprop pass.  */
 
 static unsigned int
 tree_ssa_phiprop (void)
 {
+  VEC(basic_block, heap) *bbs;
   struct phiprop_d *phivn;
+  bool did_something = false; 
+  basic_block bb;
+  gimple_stmt_iterator gsi;
+  unsigned i;
 
   calculate_dominance_info (CDI_DOMINATORS);
 
   phivn = XCNEWVEC (struct phiprop_d, num_ssa_names);
 
-  if (tree_ssa_phiprop_1 (ENTRY_BLOCK_PTR, phivn, num_ssa_names))
+  /* Walk the dominator tree in preorder.  */
+  bbs = get_all_dominated_blocks (CDI_DOMINATORS,
+                                 single_succ (ENTRY_BLOCK_PTR));
+  for (i = 0; VEC_iterate (basic_block, bbs, i, bb); ++i)
+    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      did_something |= propagate_with_phi (bb, gsi_stmt (gsi),
+                                          phivn, num_ssa_names);
+
+  if (did_something)
     gsi_commit_edge_inserts ();
 
+  VEC_free (basic_block, heap, bbs);
   free (phivn);
 
   return 0;