On 13/03/15 11:36, Richard Biener wrote:
On Fri, Mar 13, 2015 at 11:32 AM, Tom de Vries <tom_devr...@mentor.com> wrote:
Hi,

this patch moves a bunch of early-out tests from the parloops pass to the
gate function.

The only effect is for functions that we don't consider at all for
parallelization in the parloops pass. We no longer dump those in the
parloops dump file.

Bootstrapped and reg-tested on x86_64.

OK for stage1 trunk?

Does it work with -fdump-passes?


Hi,

with -fdump-passes now fixed to work on a dummy function (r222129), I'm resubmitting this patch, split up in two patches.

The first patch moves two trivial early-exit tests to the parloops gate.

The second patch moves the number_of_loops test to the parloops gate, and adds a dummy loops structure in the dummy function for -fdump-passes.

Bootstrapped and reg-tested on x86_64.

Both patches OK for trunk?

Thanks,
- Tom

Move parallelize_loops tests to parloops gate

2015-06-08  Tom de Vries  <t...@codesourcery.com>

	* tree-parloops.c (parallelize_loops): Move early-exit tests to ...
	(pass_parallelize_loops::gate): ... here.
---
 gcc/tree-parloops.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 02f44eb..a1659a3 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2535,10 +2535,6 @@ parallelize_loops (void)
   source_location loop_loc;
 
   /* Do not parallelize loops in the functions created by parallelization.  */
-  if (parallelized_function_p (cfun->decl))
-    return false;
-  if (cfun->has_nonlocal_label)
-    return false;
 
   gcc_obstack_init (&parloop_obstack);
   reduction_info_table_type reduction_list (10);
@@ -2657,7 +2653,12 @@ public:
   {}
 
   /* opt_pass methods: */
-  virtual bool gate (function *) { return flag_tree_parallelize_loops > 1; }
+  virtual bool gate (function *fun)
+    {
+      return (flag_tree_parallelize_loops > 1
+	      && !parallelized_function_p (fun->decl)
+	      && !cfun->has_nonlocal_label);
+    }
   virtual unsigned int execute (function *);
 
 }; // class pass_parallelize_loops
-- 
1.9.1

Move parloops::execute test to parloops gate

2015-06-11  Tom de Vries  <t...@codesourcery.com>

	* cfgloop.c (init_loops_structure): Add and handle dummy_p parameter.
	(flow_loops_find): Add extra argument to call to init_loops_structure.
	* cfgloop.h (init_loops_structure): Add bool parameter.
	* cgraphunit.c (init_lowered_empty_function): Add extra argument to call
	to init_loops_structure.
	* lto-streamer-in.c (input_cfg): Same.
	* tree-cfg.c (move_sese_region_to_fn): Same.
	* passes.c (pass_manager::dump_passes): Add dummy loops structure to
	dummy function.
	* tree-parloops.c (pass_parallelize_loops::execute): Move early-exit
	test to ..
	(pass_parallelize_loops::gate): ... here.
---
 gcc/cfgloop.c         | 19 +++++++++++--------
 gcc/cfgloop.h         |  2 +-
 gcc/cgraphunit.c      |  2 +-
 gcc/lto-streamer-in.c |  2 +-
 gcc/passes.c          |  4 ++++
 gcc/tree-cfg.c        |  2 +-
 gcc/tree-parloops.c   |  6 ++----
 7 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index a279046..2b17585 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -356,8 +356,8 @@ alloc_loop (void)
    (including the root of the loop tree).  */
 
 void
-init_loops_structure (struct function *fn,
-		      struct loops *loops, unsigned num_loops)
+init_loops_structure (struct function *fn, struct loops *loops,
+		      unsigned num_loops, bool dummy_p)
 {
   struct loop *root;
 
@@ -366,11 +366,14 @@ init_loops_structure (struct function *fn,
 
   /* Dummy loop containing whole function.  */
   root = alloc_loop ();
-  root->num_nodes = n_basic_blocks_for_fn (fn);
-  root->latch = EXIT_BLOCK_PTR_FOR_FN (fn);
-  root->header = ENTRY_BLOCK_PTR_FOR_FN (fn);
-  ENTRY_BLOCK_PTR_FOR_FN (fn)->loop_father = root;
-  EXIT_BLOCK_PTR_FOR_FN (fn)->loop_father = root;
+  if (!dummy_p)
+    {
+      root->num_nodes = n_basic_blocks_for_fn (fn);
+      root->latch = EXIT_BLOCK_PTR_FOR_FN (fn);
+      root->header = ENTRY_BLOCK_PTR_FOR_FN (fn);
+      ENTRY_BLOCK_PTR_FOR_FN (fn)->loop_father = root;
+      EXIT_BLOCK_PTR_FOR_FN (fn)->loop_father = root;
+    }
 
   loops->larray->quick_push (root);
   loops->tree_root = root;
@@ -427,7 +430,7 @@ flow_loops_find (struct loops *loops)
   if (!loops)
     {
       loops = ggc_cleared_alloc<struct loops> ();
-      init_loops_structure (cfun, loops, 1);
+      init_loops_structure (cfun, loops, 1, false);
     }
 
   /* Ensure that loop exits were released.  */
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index d811c56..e680941 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -260,7 +260,7 @@ struct GTY (()) loops {
 
 /* Loop recognition.  */
 bool bb_loop_header_p (basic_block);
-void init_loops_structure (struct function *, struct loops *, unsigned);
+void init_loops_structure (struct function *, struct loops *, unsigned, bool);
 extern struct loops *flow_loops_find (struct loops *);
 extern void disambiguate_loops_with_multiple_latches (void);
 extern void flow_loops_free (struct loops *);
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 722c4f4..d946b8f 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1392,7 +1392,7 @@ init_lowered_empty_function (tree decl, bool in_ssa, gcov_type count)
 			    | PROP_cfg | PROP_loops);
 
   set_loops_for_fn (cfun, ggc_cleared_alloc<loops> ());
-  init_loops_structure (cfun, loops_for_fn (cfun), 1);
+  init_loops_structure (cfun, loops_for_fn (cfun), 1, false);
   loops_for_fn (cfun)->state |= LOOPS_MAY_HAVE_MULTIPLE_LATCHES;
 
   /* Create BB for body of the function and connect it properly.  */
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 1b83615..9139c35 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -844,7 +844,7 @@ input_cfg (struct lto_input_block *ib, struct data_in *data_in,
     return;
 
   struct loops *loops = ggc_cleared_alloc<struct loops> ();
-  init_loops_structure (fn, loops, n_loops);
+  init_loops_structure (fn, loops, n_loops, false);
   set_loops_for_fn (fn, loops);
 
   /* Input each loop and associate it with its loop header so
diff --git a/gcc/passes.c b/gcc/passes.c
index 720e647..4d89fce 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -993,6 +993,10 @@ pass_manager::dump_passes () const
 {
   push_dummy_function (true);
 
+  /* Push dummy loop.  */
+  set_loops_for_fn (cfun, ggc_cleared_alloc<loops> ());
+  init_loops_structure (cfun, loops_for_fn (cfun), 1, true);
+
   create_pass_tab ();
 
   dump_pass_list (all_lowering_passes, 1);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index b8a1c86..3bb7ea1 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7122,7 +7122,7 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
 
   /* Initialize an empty loop tree.  */
   struct loops *loops = ggc_cleared_alloc<struct loops> ();
-  init_loops_structure (dest_cfun, loops, 1);
+  init_loops_structure (dest_cfun, loops, 1, false);
   loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES;
   set_loops_for_fn (dest_cfun, loops);
 
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index a1659a3..ef98878 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2657,7 +2657,8 @@ public:
     {
       return (flag_tree_parallelize_loops > 1
 	      && !parallelized_function_p (fun->decl)
-	      && !cfun->has_nonlocal_label);
+	      && !cfun->has_nonlocal_label
+	      && number_of_loops (fun) > 1);
     }
   virtual unsigned int execute (function *);
 
@@ -2666,9 +2667,6 @@ public:
 unsigned
 pass_parallelize_loops::execute (function *fun)
 {
-  if (number_of_loops (fun) <= 1)
-    return 0;
-
   if (parallelize_loops ())
     {
       fun->curr_properties &= ~(PROP_gimple_eomp);
-- 
1.9.1

Reply via email to