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]

Re: [PATCH, stage1] Make parloops gate more strict


On 14/06/15 23:49, Bernhard Reutner-Fischer wrote:
On June 14, 2015 10:55:59 AM GMT+02:00, Tom de Vries <Tom_deVries@mentor.com> wrote:
On 13/03/15 11:36, Richard Biener wrote:
On Fri, Mar 13, 2015 at 11:32 AM, Tom de Vries
<Tom_deVries@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?

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);

Now stray comment?
Stopped reading here.


Fixed in updated patch.

Also:
- made sure cfun is not used in the gate function
- added missing update of function header comment for
  init_loops_structure
- improved comment in pass_manager::dump_passes.

OK for trunk?

Thanks,
- Tom



[PATCH 1/2] Move parallelize_loops tests to parloops gate

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

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

diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 3495ac1..50b8d75 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2531,12 +2531,6 @@ parallelize_loops (void)
   HOST_WIDE_INT estimated;
   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);
   init_stmt_vec_info_vec ();
@@ -2654,7 +2648,14 @@ 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
+	      /* Do not parallelize loops in the functions created by
+		 parallelization.  */
+	      && !parallelized_function_p (fun->decl)
+	      && !fun->has_nonlocal_label);
+    }
   virtual unsigned int execute (function *);
 
 }; // class pass_parallelize_loops
-- 
1.9.1

[PATCH 2/2] Move parloops::execute test to parloops gate

2015-06-11  Tom de Vries  <tom@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         | 22 +++++++++++++---------
 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, 23 insertions(+), 17 deletions(-)

diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 20b81b3..2335ecb 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -349,11 +349,12 @@ alloc_loop (void)
 }
 
 /* Initializes loops structure LOOPS, reserving place for NUM_LOOPS loops
-   (including the root of the loop tree).  */
+   (including the root of the loop tree).  If DUMMY_P, don't use information
+   from FN.  */
 
 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;
 
@@ -362,11 +363,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;
@@ -423,7 +427,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 c73ad7f..93ef0d2 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -257,7 +257,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 3aadf28..603ed38 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1407,7 +1407,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 7729b6c..ad0d4ef 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -839,7 +839,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 d3ffe33..174ec90 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -990,6 +990,10 @@ pass_manager::dump_passes () const
 {
   push_dummy_function (true);
 
+  /* Push dummy loops structure.  */
+  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 9430151..2eae0d1 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7115,7 +7115,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 50b8d75..b056110 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2654,7 +2654,8 @@ public:
 	      /* Do not parallelize loops in the functions created by
 		 parallelization.  */
 	      && !parallelized_function_p (fun->decl)
-	      && !fun->has_nonlocal_label);
+	      && !fun->has_nonlocal_label
+	      && number_of_loops (fun) > 1);
     }
   virtual unsigned int execute (function *);
 
@@ -2663,9 +2664,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


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