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 | 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(-)
@@ -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. */
@@ -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 *);
@@ -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. */
@@ -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
@@ -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);
@@ -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);
@@ -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