diff options
author | Aditya Kumar <hiraditya@msn.com> | 2015-09-08 22:18:11 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2015-09-08 22:18:11 +0000 |
commit | 74032f471db79e96eb86a9f2ba43a36ca6c1ddcf (patch) | |
tree | 4ae633205ff90db31f378cc5d617287718e64532 /gcc/sese.c | |
parent | b71a678232eca441b374221d2544404e41fbe572 (diff) | |
download | gcc-74032f471db79e96eb86a9f2ba43a36ca6c1ddcf.zip gcc-74032f471db79e96eb86a9f2ba43a36ca6c1ddcf.tar.gz gcc-74032f471db79e96eb86a9f2ba43a36ca6c1ddcf.tar.bz2 |
Remove limit_scops
This patch removes graphite-scop-detection.c:limit_scops function and fix
related issues arising because of that. The functionality limit_scop was added
as an intermediate step to discard the loops which graphite could not
handle. Removing limit_scop required handling of different cases of loops and
surrounding code. The scop is now larger so most test cases required 'number of
scops detected' to be fixed. By increasing the size of scop we can now optimize
loops which are 'siblings' of each other. This could enable loop fusion on a
number of loops. Since in the graphite framework we mostly want to opimize
loop-nests/adjacent-loops, we now discard scops with less than 2 loops. We
also discard scops without any data references.
Essentially:
- Remove limite_scops.
- Only select scops when there are at least two loops (loop nest or, side by side).
- Discard loops without data-refs.
- Fix test cases.
Passes bootstrap and reg-test.
gcc/ChangeLog:
2015-09-02 Aditya Kumar <hiraditya@msn.com>
Sebastian Pop <s.pop@samsung.com>
* graphite-isl-ast-to-gimple.c (gcc_expression_from_isl_ast_expr_id):
Return the parameter if it was saved in corresponding
parameter_rename_map of the region.
(copy_def): Copy def from sese region to the newly created region.
(copy_internal_parameters): Copy all the internal parameters defined
within a region to the newly created region.
(graphite_regenerate_ast_isl): Copy parameters to the new region before
translating isl to gimple.
* graphite-scop-detection.c (graphite_can_represent_loop): Bail out if
the loop-nest does not have any data-references.
(build_graphite_scops): Create a scop only when there is at least one
loop inside it.
(contains_only_close_phi_nodes): Deleted.
(print_graphite_scop_statistics): Deleted
(print_graphite_statistics): Deleted
(limit_scops): Deleted.
(build_scops): Removed call to limit_scops.
* sese.c (new_sese): Construct.
(free_sese): Destruct.
(sese_add_exit_phis_edge): update_stmt after exit phi edge has been
added.
(set_rename): Pass sese region so that parameters inside the region can
be added to its parameter_rename_map.
(rename_uses): Pass sese region.
(graphite_copy_stmts_from_block): Do not copy parameters that have been
generated in the header of the scop. For each SSA_NAME in the
parameter_rename_map rename its usage.
(invariant_in_sese_p_rec): Return false if tree t is defined outside
sese region.
(scalar_evolution_in_region): If the tree t is invariant just return t.
* sese.h: Added a parameter renamne map (parameter_rename_map_t) to
struct sese to keep track of all the parameters which need renaming.
* tree-data-ref.c (loop_nest_has_data_refs): Check if a loop nest has
any data-refs.
* tree-data-ref.h: Declaration of loop_nest_has_data_refs.
gcc/testsuite/ChangeLog:
2015-09-02 Aditya Kumar <hiraditya@msn.com>
Sebastian Pop <s.pop@samsung.com>
* gcc.dg/graphite/block-0.c: Modifed test case to match current output.
* gcc.dg/graphite/block-1.c: Same.
* gcc.dg/graphite/block-5.c: Same.
* gcc.dg/graphite/block-6.c: Same.
* gcc.dg/graphite/interchange-1.c: Same.
* gcc.dg/graphite/interchange-10.c: Same.
* gcc.dg/graphite/interchange-11.c: Same.
* gcc.dg/graphite/interchange-13.c: Same.
* gcc.dg/graphite/interchange-14.c: Same.
* gcc.dg/graphite/interchange-3.c: Same.
* gcc.dg/graphite/interchange-4.c: Same.
* gcc.dg/graphite/interchange-7.c: Same.
* gcc.dg/graphite/interchange-8.c: Same.
* gcc.dg/graphite/interchange-9.c: Same.
* gcc.dg/graphite/isl-codegen-loop-dumping.c: Same.
* gcc.dg/graphite/pr35356-1.c (foo): Same.
* gcc.dg/graphite/pr37485.c: Same.
* gcc.dg/graphite/scop-0.c (int toto): Same.
* gcc.dg/graphite/scop-1.c: Same.
* gcc.dg/graphite/scop-10.c: Same.
* gcc.dg/graphite/scop-11.c: Same.
* gcc.dg/graphite/scop-12.c: Same.
* gcc.dg/graphite/scop-13.c: Same.
* gcc.dg/graphite/scop-16.c: Same.
* gcc.dg/graphite/scop-17.c: Same.
* gcc.dg/graphite/scop-18.c: Same.
* gcc.dg/graphite/scop-2.c: Same.
* gcc.dg/graphite/scop-21.c (int test): Same.
* gcc.dg/graphite/scop-22.c (void foo): Same.
* gcc.dg/graphite/scop-4.c: Same.
* gcc.dg/graphite/scop-5.c: Same.
* gcc.dg/graphite/scop-6.c: Same.
* gcc.dg/graphite/scop-7.c: Same.
* gcc.dg/graphite/scop-8.c: Same.
* gcc.dg/graphite/scop-9.c: Same.
* gcc.dg/graphite/scop-mvt.c (void mvt): Introduced dependency so that
data-refs remain inside the inner loop.
* gcc.dg/graphite/uns-block-1.c: Modifed test case to match o/p.
* gcc.dg/graphite/uns-interchange-14.c: Same.
* gcc.dg/graphite/uns-interchange-9.c: Same.
* gfortran.dg/graphite/interchange-3.f90
libgomp/ChangeLog:
2015-09-04 Aditya Kumar <hiraditya@msn.com>
Sebastian Pop <s.pop@samsung.com>
* testsuite/libgomp.graphite/bounds.c (int foo): Modifed test case to
match o/p.
* testsuite/libgomp.graphite/force-parallel-1.c (void parloop): Same.
* testsuite/libgomp.graphite/force-parallel-4.c: Same.
* testsuite/libgomp.graphite/force-parallel-5.c: Same.
* testsuite/libgomp.graphite/force-parallel-7.c: Same.
* testsuite/libgomp.graphite/force-parallel-8.c: Same.
Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r227567
Diffstat (limited to 'gcc/sese.c')
-rw-r--r-- | gcc/sese.c | 80 |
1 files changed, 75 insertions, 5 deletions
@@ -267,6 +267,7 @@ new_sese (edge entry, edge exit) SESE_LOOP_NEST (region).create (3); SESE_ADD_PARAMS (region) = true; SESE_PARAMS (region).create (3); + region->parameter_rename_map = new parameter_rename_map_t; return region; } @@ -281,6 +282,8 @@ free_sese (sese region) SESE_PARAMS (region).release (); SESE_LOOP_NEST (region).release (); + delete region->parameter_rename_map; + region->parameter_rename_map = NULL; XDELETE (region); } @@ -294,6 +297,7 @@ sese_add_exit_phis_edge (basic_block exit, tree use, edge false_e, edge true_e) create_new_def_for (use, phi, gimple_phi_result_ptr (phi)); add_phi_arg (phi, use, false_e, UNKNOWN_LOCATION); add_phi_arg (phi, use, true_e, UNKNOWN_LOCATION); + update_stmt (phi); } /* Insert in the block BB phi nodes for variables defined in REGION @@ -373,12 +377,19 @@ get_rename (rename_map_type *rename_map, tree old_name) /* Register in RENAME_MAP the rename tuple (OLD_NAME, EXPR). */ static void -set_rename (rename_map_type *rename_map, tree old_name, tree expr) +set_rename (rename_map_type *rename_map, tree old_name, tree expr, sese region) { if (old_name == expr) return; rename_map->put (old_name, expr); + + tree t; + int i; + /* For a parameter of a scop we dont want to rename it. */ + FOR_EACH_VEC_ELT (SESE_PARAMS (region), i, t) + if (old_name == t) + region->parameter_rename_map->put(old_name, expr); } /* Renames the scalar uses of the statement COPY, using the @@ -484,7 +495,7 @@ rename_uses (gimple copy, rename_map_type *rename_map, recompute_tree_invariant_for_addr_expr (rhs); } - set_rename (rename_map, old_name, new_expr); + set_rename (rename_map, old_name, new_expr, region); } return changed; @@ -525,6 +536,14 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, && scev_analyzable_p (lhs, region)) continue; + /* Do not copy parameters that have been generated in the header of the + scop. */ + if (is_gimple_assign (stmt) + && (lhs = gimple_assign_lhs (stmt)) + && TREE_CODE (lhs) == SSA_NAME + && region->parameter_rename_map->get(lhs)) + continue; + /* Create a new copy of STMT and duplicate STMT's virtual operands. */ copy = gimple_copy (stmt); @@ -539,7 +558,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, { tree old_name = DEF_FROM_PTR (def_p); tree new_name = create_new_def_for (old_name, copy, def_p); - set_rename (rename_map, old_name, new_name); + set_rename (rename_map, old_name, new_name, region); } if (rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map, @@ -549,6 +568,25 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, fold_stmt_inplace (&gsi_tgt); } + /* For each SSA_NAME in the parameter_rename_map rename their usage. */ + ssa_op_iter iter; + use_operand_p use_p; + if (!is_gimple_debug (copy)) + FOR_EACH_SSA_USE_OPERAND (use_p, copy, iter, SSA_OP_USE) + { + tree old_name = USE_FROM_PTR (use_p); + + if (TREE_CODE (old_name) != SSA_NAME + || SSA_NAME_IS_DEFAULT_DEF (old_name)) + continue; + + tree *new_expr = region->parameter_rename_map->get (old_name); + if (!new_expr) + continue; + + replace_exp (use_p, *new_expr); + } + update_stmt (copy); } } @@ -722,6 +760,35 @@ set_ifsese_condition (ifsese if_region, tree condition) gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT); } +/* Return false if T is completely defined outside REGION. */ + +static bool +invariant_in_sese_p_rec (tree t, sese region) +{ + ssa_op_iter iter; + use_operand_p use_p; + if (!defined_in_sese_p (t, region)) + return true; + + gimple stmt = SSA_NAME_DEF_STMT (t); + + if (gimple_code (stmt) == GIMPLE_PHI + || gimple_code (stmt) == GIMPLE_CALL) + return false; + + FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE) + { + tree use = USE_FROM_PTR (use_p); + if (!defined_in_sese_p (use, region)) + continue; + + if (!invariant_in_sese_p_rec (use, region)) + return false; + } + + return true; +} + /* Returns the scalar evolution of T in REGION. Every variable that is not defined in the REGION is considered a parameter. */ @@ -752,6 +819,9 @@ scalar_evolution_in_region (sese region, loop_p loop, tree t) t = compute_overall_effect_of_inner_loop (def_loop, t); return t; } - else - return instantiate_scev (before, loop, t); + + if (invariant_in_sese_p_rec (t, region)) + return t; + + return instantiate_scev (before, loop, t); } |