Patchwork [5/6] Call if-conversion from loop flattening.

login
register
mail settings
Submitter Sebastian Pop
Date Oct. 28, 2010, 10:58 p.m.
Message ID <1288306702-5543-6-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/69511/
State New
Headers show

Comments

Sebastian Pop - Oct. 28, 2010, 10:58 p.m.
2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>

	* passes.c (init_optimization_passes): Do not call pass_if_conversion
	after pass_flatten_loops.
	* tree-flow.h (gate_tree_if_conversion): Declared.
	(tree_if_conversion): Declared.
	* tree-if-conv.c (tree_if_conversion): Not static anymore.
	(gate_tree_if_conversion): Same.
	* tree-loop-flattening.c (flatten_loop): Extra param.
	Call gate_tree_if_conversion and tree_if_conversion.
	(tree_loop_flattening): Pass to flatten_loop an extra param.
---
 gcc/ChangeLog              |   12 ++++++++++++
 gcc/passes.c               |    1 -
 gcc/tree-flow.h            |    4 ++++
 gcc/tree-if-conv.c         |    4 ++--
 gcc/tree-loop-flattening.c |   11 ++++++++---
 5 files changed, 26 insertions(+), 6 deletions(-)

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4439226..8907244 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,17 @@ 
 2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* passes.c (init_optimization_passes): Do not call pass_if_conversion
+	after pass_flatten_loops.
+	* tree-flow.h (gate_tree_if_conversion): Declared.
+	(tree_if_conversion): Declared.
+	* tree-if-conv.c (tree_if_conversion): Not static anymore.
+	(gate_tree_if_conversion): Same.
+	* tree-loop-flattening.c (flatten_loop): Extra param.
+	Call gate_tree_if_conversion and tree_if_conversion.
+	(tree_loop_flattening): Pass to flatten_loop an extra param.
+
+2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* tree-if-conv.c (if_convertible_loop_p_1): Do not call
 	compute_data_dependences_for_loop.
 	(if_convertible_loop_p): Do not free refs and ddrs.
diff --git a/gcc/passes.c b/gcc/passes.c
index 4b778bc..ed81018 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -914,7 +914,6 @@  init_optimization_passes (void)
           NEXT_PASS (pass_predcom);
 	  NEXT_PASS (pass_complete_unroll);
 	  NEXT_PASS (pass_flatten_loops);
-	  NEXT_PASS (pass_if_conversion);
 	  NEXT_PASS (pass_slp_vectorize);
 	  NEXT_PASS (pass_parallelize_loops);
 	  NEXT_PASS (pass_loop_prefetch);
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index c2702dc..e1ee69f 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -730,6 +730,10 @@  bool contains_abnormal_ssa_name_p (tree);
 bool stmt_dominates_stmt_p (gimple, gimple);
 void mark_virtual_ops_for_renaming (gimple);
 
+/* In tree-if-conv.c */
+bool gate_tree_if_conversion (void);
+bool tree_if_conversion (struct loop *, tree *);
+
 /* In tree-ssa-dce.c */
 void mark_virtual_phi_result_for_renaming (gimple);
 
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index f05213e..5ee4599 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -1599,7 +1599,7 @@  combine_blocks (struct loop *loop, tree *scratch_pad)
 /* If-convert LOOP when it is legal.  For the moment this pass has no
    profitability analysis.  Returns true when something changed.  */
 
-static bool
+bool
 tree_if_conversion (struct loop *loop, tree *scratch_pad)
 {
   bool changed = false;
@@ -1662,7 +1662,7 @@  main_tree_if_conversion (void)
 
 /* Returns true when the if-conversion pass is enabled.  */
 
-static bool
+bool
 gate_tree_if_conversion (void)
 {
   return ((flag_tree_vectorize && flag_tree_loop_if_convert != 0)
diff --git a/gcc/tree-loop-flattening.c b/gcc/tree-loop-flattening.c
index 826e7e8..4bc8768 100644
--- a/gcc/tree-loop-flattening.c
+++ b/gcc/tree-loop-flattening.c
@@ -497,10 +497,11 @@  add_missing_phi_nodes (loop_p loop)
   free (bbs);
 }
 
-/* Removes all the back-edges of LOOP except its own back-edge.  */
+/* Removes all the back-edges of LOOP except its own back-edge.
+   SCRATCH_PAD is used in if-conversion.  */
 
 static unsigned
-flatten_loop (loop_p loop)
+flatten_loop (loop_p loop, tree *scratch_pad)
 {
   int i, n = loop->num_nodes;
   basic_block *bbs;
@@ -570,6 +571,9 @@  flatten_loop (loop_p loop)
   if (!single_pred_p (loop->latch))
     loop->latch = split_edge (loop_latch_edge (loop));
 
+  if (gate_tree_if_conversion ())
+    tree_if_conversion (loop, scratch_pad);
+
   return TODO_update_ssa | TODO_verify_ssa;
 }
 
@@ -581,12 +585,13 @@  tree_loop_flattening (void)
   unsigned todo = 0;
   loop_p loop;
   loop_iterator li;
+  tree scratch_pad = NULL_TREE;
 
   if (number_of_loops () <= 1)
     return 0;
 
   FOR_EACH_LOOP (li, loop, 0)
-    todo |= flatten_loop (loop);
+    todo |= flatten_loop (loop, &scratch_pad);
 
 #ifdef ENABLE_CHECKING
   verify_dominators (CDI_DOMINATORS);