This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa][PATCH]: Add splitting critical edges as a pass


Currently, split_critical_edges gets charged in time to SSAPRE. With ENABLE_CHECKING on, verify_dominators can be quite expensive after the split_critical_edges call (100 seconds on 20001226-1.c).

Rather than just push/pop a timevar in tree-ssa-pre.c, I decided to make no_critical_edges a property, and make SSAPRE require it, and split_critical_edges provide it.
That way, something could eventually manage it.


(BTW I abbreviated parts of the timevar description because otherwise it is too long and looks really ugly in the table)

Hopefully non-controversial, but still needs an approval.

Bootstrapped and regtested on darwin and i686-pc-linux-gnu


2004-01-18 Daniel Berlin <dberlin@dberlin.org>


	* timevar.def (TV_TREE_SPLIT_EDGES): New timevar.
	* tree-ssa-pre.c (split_critical_edges): Move from here
	(pass_pre): Add PROP_no_crit_edges as required.
	* tree-cfg.c (split_critical_edges): to here.
	(pass_split_crit_edges): New pass.
	* tree-optimize.c (tree_optimization_passes): Add NEXT_PASS
	(split_crit_edges).
	* tree-pass.h: Add PROP_no_crit_edges.
	(pass_split_crit_edges): Declared.
Index: timevar.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/timevar.def,v
retrieving revision 1.14.2.29
diff -u -3 -p -r1.14.2.29 timevar.def
--- timevar.def	7 Jan 2004 23:44:14 -0000	1.14.2.29
+++ timevar.def	19 Jan 2004 17:33:12 -0000
@@ -72,6 +72,7 @@ DEFTIMEVAR (TV_TREE_DFA	             , "
 DEFTIMEVAR (TV_TREE_SSA_DOMINATOR_OPTS   , "dominator optimization")
 DEFTIMEVAR (TV_TREE_SRA              , "tree SRA")
 DEFTIMEVAR (TV_TREE_CCP		     , "tree CCP")
+DEFTIMEVAR (TV_TREE_SPLIT_EDGES, "tree split crit edges")
 DEFTIMEVAR (TV_TREE_PRE		     , "tree PRE")
 DEFTIMEVAR (TV_TREE_DCE		     , "tree DCE")
 DEFTIMEVAR (TV_TREE_LOOP	     , "tree loop optimization")
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.258
diff -u -3 -p -r1.1.4.258 tree-cfg.c
--- tree-cfg.c	18 Jan 2004 22:59:28 -0000	1.1.4.258
+++ tree-cfg.c	19 Jan 2004 17:33:14 -0000
@@ -94,6 +94,8 @@ static void make_switch_expr_edges (basi
 static void make_goto_expr_edges (basic_block);
 static edge tree_redirect_edge_and_branch (edge, basic_block);
 static edge tree_try_redirect_by_replacing_jump (edge, basic_block);
+static void split_critical_edges (void);
+

 /* Various helpers.  */
 static inline bool stmt_starts_bb_p (tree, tree);
@@ -3926,4 +3929,40 @@ struct cfg_hooks tree_cfg_hooks = {
   NULL				/* tidy_fallthru_edge  */
 };

+
+/* Split all critical edges.  */
+
+static void
+split_critical_edges (void)
+{
+  basic_block bb;
+  edge e;
+
+  FOR_ALL_BB (bb)
+    {
+      for (e = bb->succ; e ; e = e->succ_next)
+	if (EDGE_CRITICAL_P (e) && !(e->flags & EDGE_ABNORMAL))
+	  {
+	    split_edge (e);
+	  }
+    }
+
+}
+
+struct tree_opt_pass pass_split_crit_edges =
+{
+  NULL,                          /* name */
+  NULL,                          /* gate */
+  split_critical_edges,          /* execute */
+  NULL,                          /* sub */
+  NULL,                          /* next */
+  0,                             /* static_pass_number */
+  TV_TREE_SPLIT_EDGES,           /* tv_id */
+  PROP_cfg,                      /* properties required */
+  PROP_no_crit_edges,            /* properties_provided */
+  0,                             /* properties_destroyed */
+  0,                             /* todo_flags_start */
+  0,                             /* todo_flags_finish */
+};
+
 #include "gt-tree-cfg.h"
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.112
diff -u -3 -p -r1.1.4.112 tree-optimize.c
--- tree-optimize.c	19 Jan 2004 01:40:51 -0000	1.1.4.112
+++ tree-optimize.c	19 Jan 2004 17:33:14 -0000
@@ -293,6 +293,7 @@ init_tree_optimization_passes (void)
   NEXT_PASS (pass_loop);
   NEXT_PASS (pass_ccp);
   NEXT_PASS (pass_fold_builtins);
+  NEXT_PASS (pass_split_crit_edges);
   NEXT_PASS (pass_pre);
   NEXT_PASS (DUP_PASS (pass_dominator));
   NEXT_PASS (DUP_PASS (pass_dce));
Index: tree-pass.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pass.h,v
retrieving revision 1.1.2.4
diff -u -3 -p -r1.1.2.4 tree-pass.h
--- tree-pass.h	19 Jan 2004 01:40:51 -0000	1.1.2.4
+++ tree-pass.h	19 Jan 2004 17:33:14 -0000
@@ -74,6 +74,7 @@ struct tree_opt_pass
 #define PROP_referenced_vars	(1 << 4)
 #define PROP_pta		(1 << 5)
 #define PROP_ssa		(1 << 6)
+#define PROP_no_crit_edges      (1 << 7)

/* To-do flags. */
#define TODO_dump_func (1 << 0) /* pass doesn't dump itself */
@@ -107,6 +108,7 @@ extern struct tree_opt_pass pass_del_ssa
extern struct tree_opt_pass pass_dominator;
extern struct tree_opt_pass pass_dce;
extern struct tree_opt_pass pass_may_alias;
+extern struct tree_opt_pass pass_split_crit_edges;
extern struct tree_opt_pass pass_pre;
extern struct tree_opt_pass pass_profile;
extern struct tree_opt_pass pass_lower_complex;
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.123
diff -u -3 -p -r1.1.4.123 tree-ssa-pre.c
--- tree-ssa-pre.c 15 Jan 2004 06:43:19 -0000 1.1.4.123
+++ tree-ssa-pre.c 19 Jan 2004 17:33:15 -0000
@@ -238,7 +238,6 @@ static void compute_du_info (struct expr
static void add_ephi_use (tree, tree, int);
static void insert_one_operand (struct expr_info *, tree, int, tree, edge,
tree **);
-static bool split_critical_edges (void);
static void collect_expressions (basic_block, varray_type *);
static int build_dfn_array (basic_block, int);
static int eref_compare (const void *, const void *);
@@ -3013,27 +3012,6 @@ pre_expression (struct expr_info *slot,
return 0;
}


-/* Split all critical edges.  */
-
-static bool
-split_critical_edges (void)
-{
-  bool did_something = false;
-  basic_block bb;
-  edge e;
-
-  FOR_ALL_BB (bb)
-    {
-      for (e = bb->succ; e ; e = e->succ_next)
-	if (EDGE_CRITICAL_P (e) && !(e->flags & EDGE_ABNORMAL))
-	  {
-	    split_edge (e);
-	    did_something = true;
-	  }
-    }
-
-  return did_something;
-}

/* Step 1 - Collect the expressions to perform PRE on. */

@@ -3150,8 +3128,6 @@ execute_pre (void)
   size_t k;
   int i;

-  split_critical_edges ();
-
   if (ENTRY_BLOCK_PTR->succ->dest->pred->pred_next)
     if (!(ENTRY_BLOCK_PTR->succ->flags & EDGE_ABNORMAL))
       split_edge (ENTRY_BLOCK_PTR->succ);
@@ -3239,7 +3215,7 @@ struct tree_opt_pass pass_pre =
   NULL,					/* next */
   0,					/* static_pass_number */
   TV_TREE_PRE,				/* tv_id */
-  PROP_cfg | PROP_ssa,			/* properties_required */
+  PROP_no_crit_edges | PROP_cfg | PROP_ssa,/* properties_required */
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]