From 74032f471db79e96eb86a9f2ba43a36ca6c1ddcf Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Tue, 8 Sep 2015 22:18:11 +0000 Subject: [PATCH] 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 Sebastian Pop * 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 Sebastian Pop * 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 Sebastian Pop * 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 From-SVN: r227567 --- gcc/ChangeLog | 39 ++++ gcc/graphite-isl-ast-to-gimple.c | 81 +++++++- gcc/graphite-scop-detection.c | 173 +++--------------- gcc/sese.c | 80 +++++++- gcc/sese.h | 5 + gcc/testsuite/ChangeLog | 45 +++++ gcc/testsuite/gcc.dg/graphite/block-0.c | 2 +- gcc/testsuite/gcc.dg/graphite/block-1.c | 2 +- gcc/testsuite/gcc.dg/graphite/block-5.c | 2 +- gcc/testsuite/gcc.dg/graphite/block-6.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-1.c | 2 +- .../gcc.dg/graphite/interchange-10.c | 2 +- .../gcc.dg/graphite/interchange-11.c | 2 +- .../gcc.dg/graphite/interchange-13.c | 2 +- .../gcc.dg/graphite/interchange-14.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-3.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-4.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-7.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-8.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-9.c | 2 +- .../graphite/isl-codegen-loop-dumping.c | 4 +- gcc/testsuite/gcc.dg/graphite/pr35356-1.c | 4 + gcc/testsuite/gcc.dg/graphite/pr37485.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-0.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-1.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-10.c | 4 +- gcc/testsuite/gcc.dg/graphite/scop-11.c | 3 +- gcc/testsuite/gcc.dg/graphite/scop-12.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-13.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-16.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-17.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-18.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-2.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-21.c | 3 + gcc/testsuite/gcc.dg/graphite/scop-22.c | 3 + gcc/testsuite/gcc.dg/graphite/scop-4.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-5.c | 4 +- gcc/testsuite/gcc.dg/graphite/scop-6.c | 3 +- gcc/testsuite/gcc.dg/graphite/scop-7.c | 3 +- gcc/testsuite/gcc.dg/graphite/scop-8.c | 5 +- gcc/testsuite/gcc.dg/graphite/scop-9.c | 4 +- gcc/testsuite/gcc.dg/graphite/scop-mvt.c | 6 +- gcc/testsuite/gcc.dg/graphite/uns-block-1.c | 2 +- .../gcc.dg/graphite/uns-interchange-14.c | 2 +- .../gcc.dg/graphite/uns-interchange-9.c | 2 +- .../gfortran.dg/graphite/interchange-3.f90 | 2 +- gcc/tree-data-ref.c | 43 +++++ gcc/tree-data-ref.h | 1 + libgomp/ChangeLog | 11 ++ libgomp/testsuite/libgomp.graphite/bounds.c | 2 + .../libgomp.graphite/force-parallel-1.c | 7 +- .../libgomp.graphite/force-parallel-4.c | 1 - .../libgomp.graphite/force-parallel-5.c | 2 +- .../libgomp.graphite/force-parallel-7.c | 2 +- .../libgomp.graphite/force-parallel-8.c | 2 - 55 files changed, 381 insertions(+), 215 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d8dd36a6de1..dbd0bd6ad25 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,42 @@ +2015-09-08 Aditya Kumar + Sebastian Pop + + * 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. + 2015-09-08 Tom de Vries * Makefile.in (generated_files): Add params.list. diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index 5434bfdeb6f..a8c99c3faad 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -57,7 +57,9 @@ extern "C" { #include "tree-ssa-loop-manip.h" #include "tree-scalar-evolution.h" #include "gimple-ssa.h" +#include "tree-phinodes.h" #include "tree-into-ssa.h" +#include "ssa-iterators.h" #include #include "graphite-isl-ast-to-gimple.h" @@ -286,7 +288,12 @@ gcc_expression_from_isl_ast_expr_id (tree type, gcc_assert (res != ip.end () && "Could not map isl_id to tree expression"); isl_ast_expr_free (expr_id); - return fold_convert (type, res->second); + tree t = res->second; + tree *val = region->parameter_rename_map->get(t); + + if (!val) + val = &t; + return fold_convert (type, *val); } /* Converts an isl_ast_expr_int expression E to a GCC expression tree of @@ -1063,6 +1070,69 @@ scop_to_isl_ast (scop_p scop, ivs_params &ip) return ast_isl; } +/* Copy def from sese REGION to the newly created TO_REGION. TR is defined by + DEF_STMT. GSI points to entry basic block of the TO_REGION. */ + +static void +copy_def(tree tr, gimple def_stmt, sese region, sese to_region, gimple_stmt_iterator *gsi) +{ + if (!defined_in_sese_p (tr, region)) + return; + ssa_op_iter iter; + use_operand_p use_p; + + FOR_EACH_SSA_USE_OPERAND (use_p, def_stmt, iter, SSA_OP_USE) + { + tree use_tr = USE_FROM_PTR (use_p); + + /* Do not copy parameters that have been generated in the header of the + scop. */ + if (region->parameter_rename_map->get(use_tr)) + continue; + + gimple def_of_use = SSA_NAME_DEF_STMT (use_tr); + if (!def_of_use) + continue; + + copy_def (use_tr, def_of_use, region, to_region, gsi); + } + + gimple copy = gimple_copy (def_stmt); + gsi_insert_after (gsi, copy, GSI_NEW_STMT); + + /* Create new names for all the definitions created by COPY and + add replacement mappings for each new name. */ + def_operand_p def_p; + ssa_op_iter op_iter; + FOR_EACH_SSA_DEF_OPERAND (def_p, copy, op_iter, SSA_OP_ALL_DEFS) + { + tree old_name = DEF_FROM_PTR (def_p); + tree new_name = create_new_def_for (old_name, copy, def_p); + region->parameter_rename_map->put(old_name, new_name); + } + + update_stmt (copy); +} + +static void +copy_internal_parameters(sese region, sese to_region) +{ + /* For all the parameters which definitino is in the if_region->false_region, + insert code on true_region (if_region->true_region->entry). */ + + int i; + tree tr; + gimple_stmt_iterator gsi = gsi_start_bb(to_region->entry->dest); + + FOR_EACH_VEC_ELT (region->params, i, tr) + { + // If def is not in region. + gimple def_stmt = SSA_NAME_DEF_STMT (tr); + if (def_stmt) + copy_def (tr, def_stmt, region, to_region, &gsi); + } +} + /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for the given SCOP. Return true if code generation succeeded. @@ -1102,10 +1172,13 @@ graphite_regenerate_ast_isl (scop_p scop) context_loop = SESE_ENTRY (region)->src->loop_father; - translate_isl_ast_to_gimple t (region); + /* Copy all the parameters which are defined in the region. */ + copy_internal_parameters(if_region->false_region, if_region->true_region); - t.translate_isl_ast (context_loop, root_node, if_region->true_region->entry, - ip); + translate_isl_ast_to_gimple t(region); + edge e = single_succ_edge (if_region->true_region->entry->dest); + split_edge (e); + t.translate_isl_ast (context_loop, root_node, e, ip); mark_virtual_operands_for_renaming (cfun); update_ssa (TODO_update_ssa); diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index dbd98428265..3ac56dedd04 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -472,6 +472,17 @@ graphite_can_represent_loop (basic_block scop_entry, loop_p loop) tree niter; struct tree_niter_desc niter_desc; + if (!loop_nest_has_data_refs (loop)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "[scop-detection-fail] "); + fprintf (dump_file, "Loop %d does not have any data reference.\n", + loop->num); + } + return false; + } + /* FIXME: For the moment, graphite cannot be used on loops that iterate using induction variables that wrap. */ @@ -1155,8 +1166,17 @@ build_graphite_scops (vec regions, if (!exit) continue; - scop = new_scop (new_sese (entry, exit)); - scops->safe_push (scop); + sese sese_reg = new_sese (entry, exit); + scop = new_scop (sese_reg); + + build_sese_loop_nests (sese_reg); + + /* Scops with one or no loops are not interesting. */ + if (SESE_LOOP_NEST (sese_reg).length () > 1) + scops->safe_push (scop); + else if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Discarded scop: %d loops\n", + SESE_LOOP_NEST (sese_reg).length ()); /* Are there overlapping SCoPs? */ #ifdef ENABLE_CHECKING @@ -1172,151 +1192,6 @@ build_graphite_scops (vec regions, } } -/* Returns true when BB contains only close phi nodes. */ - -static bool -contains_only_close_phi_nodes (basic_block bb) -{ - gimple_stmt_iterator gsi; - - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - if (gimple_code (gsi_stmt (gsi)) != GIMPLE_LABEL) - return false; - - return true; -} - -/* Print statistics for SCOP to FILE. */ - -static void -print_graphite_scop_statistics (FILE* file, scop_p scop) -{ - long n_bbs = 0; - long n_loops = 0; - long n_stmts = 0; - long n_conditions = 0; - long n_p_bbs = 0; - long n_p_loops = 0; - long n_p_stmts = 0; - long n_p_conditions = 0; - - basic_block bb; - - FOR_ALL_BB_FN (bb, cfun) - { - gimple_stmt_iterator psi; - loop_p loop = bb->loop_father; - - if (!bb_in_sese_p (bb, SCOP_REGION (scop))) - continue; - - n_bbs++; - n_p_bbs += bb->count; - - if (EDGE_COUNT (bb->succs) > 1) - { - n_conditions++; - n_p_conditions += bb->count; - } - - for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi)) - { - n_stmts++; - n_p_stmts += bb->count; - } - - if (loop->header == bb && loop_in_sese_p (loop, SCOP_REGION (scop))) - { - n_loops++; - n_p_loops += bb->count; - } - - } - - fprintf (file, "\nBefore limit_scops SCoP statistics ("); - fprintf (file, "BBS:%ld, ", n_bbs); - fprintf (file, "LOOPS:%ld, ", n_loops); - fprintf (file, "CONDITIONS:%ld, ", n_conditions); - fprintf (file, "STMTS:%ld)\n", n_stmts); - fprintf (file, "\nBefore limit_scops SCoP profiling statistics ("); - fprintf (file, "BBS:%ld, ", n_p_bbs); - fprintf (file, "LOOPS:%ld, ", n_p_loops); - fprintf (file, "CONDITIONS:%ld, ", n_p_conditions); - fprintf (file, "STMTS:%ld)\n", n_p_stmts); -} - -/* Print statistics for SCOPS to FILE. */ - -static void -print_graphite_statistics (FILE* file, vec scops) -{ - int i; - scop_p scop; - - FOR_EACH_VEC_ELT (scops, i, scop) - print_graphite_scop_statistics (file, scop); -} - -/* We limit all SCoPs to SCoPs, that are completely surrounded by a loop. - - Example: - - for (i | - { | - for (j | SCoP 1 - for (k | - } | - - * SCoP frontier, as this line is not surrounded by any loop. * - - for (l | SCoP 2 - - This is necessary as scalar evolution and parameter detection need a - outermost loop to initialize parameters correctly. - - TODO: FIX scalar evolution and parameter detection to allow more flexible - SCoP frontiers. */ - -static void -limit_scops (vec *scops) -{ - auto_vec regions; - - int i; - scop_p scop; - - FOR_EACH_VEC_ELT (*scops, i, scop) - { - int j; - loop_p loop; - sese region = SCOP_REGION (scop); - build_sese_loop_nests (region); - - FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region), j, loop) - if (!loop_in_sese_p (loop_outer (loop), region) - && single_exit (loop)) - { - sd_region open_scop; - open_scop.entry = loop->header; - open_scop.exit = single_exit (loop)->dest; - - /* This is a hack on top of the limit_scops hack. The - limit_scops hack should disappear all together. */ - if (single_succ_p (open_scop.exit) - && contains_only_close_phi_nodes (open_scop.exit)) - open_scop.exit = single_succ_edge (open_scop.exit)->dest; - - regions.safe_push (open_scop); - } - } - - free_scops (*scops); - scops->create (3); - - create_sese_edges (regions); - build_graphite_scops (regions, scops); -} - /* Returns true when P1 and P2 are close phis with the same argument. */ @@ -1501,10 +1376,6 @@ build_scops (vec *scops) create_sese_edges (regions); build_graphite_scops (regions, scops); - if (dump_file && (dump_flags & TDF_DETAILS)) - print_graphite_statistics (dump_file, *scops); - - limit_scops (scops); regions.release (); if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/sese.c b/gcc/sese.c index 2dedd9516b6..3b716f54e1a 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -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); } diff --git a/gcc/sese.h b/gcc/sese.h index 52aa8688cbf..b025a4dd821 100644 --- a/gcc/sese.h +++ b/gcc/sese.h @@ -22,6 +22,8 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_SESE_H #define GCC_SESE_H +typedef hash_map parameter_rename_map_t; + /* A Single Entry, Single Exit region is a part of the CFG delimited by two edges. */ typedef struct sese_s @@ -32,6 +34,9 @@ typedef struct sese_s /* Parameters used within the SCOP. */ vec params; + /* Parameters to be renamed. */ + parameter_rename_map_t *parameter_rename_map; + /* Loops completely contained in the SCOP. */ bitmap loops; vec loop_nest; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 74652c315fb..7ba0c06ea44 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,48 @@ +2015-09-08 Aditya Kumar + Sebastian Pop + + * 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 + 2015-09-08 Alan Lawrence PR target/63870 diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c index cb08a5fe56f..24b3bd060a9 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-0.c +++ b/gcc/testsuite/gcc.dg/graphite/block-0.c @@ -42,4 +42,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "not tiled" 3 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "not tiled" 2 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-1.c b/gcc/testsuite/gcc.dg/graphite/block-1.c index 19f9f20c3bc..bb81a95d421 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-1.c +++ b/gcc/testsuite/gcc.dg/graphite/block-1.c @@ -45,4 +45,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 5 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 6 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-5.c b/gcc/testsuite/gcc.dg/graphite/block-5.c index d30abf80fda..2f4b2f503b0 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-5.c +++ b/gcc/testsuite/gcc.dg/graphite/block-5.c @@ -53,4 +53,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-6.c b/gcc/testsuite/gcc.dg/graphite/block-6.c index 9f03448b957..36e9783d151 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-6.c +++ b/gcc/testsuite/gcc.dg/graphite/block-6.c @@ -48,4 +48,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-1.c b/gcc/testsuite/gcc.dg/graphite/interchange-1.c index b9f12c7d20d..2c58ac21e98 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-1.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-1.c @@ -49,4 +49,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-10.c b/gcc/testsuite/gcc.dg/graphite/interchange-10.c index 29e11c72257..9d486448d08 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-10.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-10.c @@ -46,4 +46,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 6 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-11.c b/gcc/testsuite/gcc.dg/graphite/interchange-11.c index afd71230a63..4f6918dc691 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-11.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-11.c @@ -46,4 +46,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-13.c b/gcc/testsuite/gcc.dg/graphite/interchange-13.c index 0e722e2632e..c9ea048e482 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-13.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-13.c @@ -50,4 +50,4 @@ main (void) } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-14.c b/gcc/testsuite/gcc.dg/graphite/interchange-14.c index 55c600247c0..151bfe71f1f 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-14.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-14.c @@ -54,4 +54,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 7 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 6 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-3.c b/gcc/testsuite/gcc.dg/graphite/interchange-3.c index cdc02020197..ebdeef7ea8e 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-3.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-3.c @@ -47,4 +47,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-4.c b/gcc/testsuite/gcc.dg/graphite/interchange-4.c index 67125658286..9a50e7a0833 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-4.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-4.c @@ -46,4 +46,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-7.c b/gcc/testsuite/gcc.dg/graphite/interchange-7.c index d99a16a291a..e53d30e8cfe 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-7.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-7.c @@ -46,4 +46,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-8.c b/gcc/testsuite/gcc.dg/graphite/interchange-8.c index 123106bb475..c5e714175a0 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-8.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-8.c @@ -82,4 +82,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 5 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 6 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-9.c b/gcc/testsuite/gcc.dg/graphite/interchange-9.c index e4c54ae181d..44a5452213e 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-9.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-9.c @@ -44,4 +44,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c b/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c index cb5d802db8e..70ac24c46d7 100644 --- a/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c +++ b/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c @@ -12,4 +12,6 @@ main (int n, int *a) return 0; } -/* { dg-final { scan-tree-dump-times "ISL AST generated by ISL: \nfor \\(int c1 = 0; c1 < n - 1; c1 \\+= 1\\)\n for \\(int c3 = 0; c3 < n; c3 \\+= 1\\)\n S_4\\(c1, c3\\);" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "ISL AST generated by ISL: \n\\{\n S_2\\();\n if \\(P_19 >= 1\\)\n + for \\(int c1 = 0; c1 < n - 1; c1 \\+= 1\\) \\{ \n for \\(int c3 = 0; c3 < n; c3 \\+= 1\\)\n + S_4\\(c1, c3\\); \n S_6\\(c1\\);\n \\} \n\\}" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr35356-1.c b/gcc/testsuite/gcc.dg/graphite/pr35356-1.c index 10aa49337b7..7f0e8246e03 100644 --- a/gcc/testsuite/gcc.dg/graphite/pr35356-1.c +++ b/gcc/testsuite/gcc.dg/graphite/pr35356-1.c @@ -7,6 +7,10 @@ foo (int bar, int n, int k) { int i; + for (i = 0; i < n; i++) + if (i == k) + a[i] = bar; + for (i = 0; i < n; i++) if (i == k) a[i] = bar; diff --git a/gcc/testsuite/gcc.dg/graphite/pr37485.c b/gcc/testsuite/gcc.dg/graphite/pr37485.c index 0a6dfbceefc..47138d303af 100644 --- a/gcc/testsuite/gcc.dg/graphite/pr37485.c +++ b/gcc/testsuite/gcc.dg/graphite/pr37485.c @@ -31,4 +31,4 @@ void fallbackSort ( UInt32* fmap, AssertH ( j < 256, 1005 ); } -/* { dg-final { scan-tree-dump-times "tiled by" 1 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-0.c b/gcc/testsuite/gcc.dg/graphite/scop-0.c index 9cfd5dd14dc..abeabce98a8 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-0.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-0.c @@ -9,7 +9,7 @@ int toto() int b[100]; int N = foo (); - for (i = 0; i < 2*N+ 100; i++) + for (i = 0; i < N+ 100; i++) for (j = 0; j < 200; j++) a[j][i] = a[j+1][10] + 2; diff --git a/gcc/testsuite/gcc.dg/graphite/scop-1.c b/gcc/testsuite/gcc.dg/graphite/scop-1.c index 16070d425b8..a569065d095 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-1.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-1.c @@ -27,4 +27,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-10.c b/gcc/testsuite/gcc.dg/graphite/scop-10.c index f14aabce4c3..39ed5d7ea7b 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-10.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-10.c @@ -12,8 +12,6 @@ int toto() b[i+j] = b[i+j-1] + 2; if (i * 2 == i + 8) - bar (); - else { for (j = 1; j < 100; j++) b[i+j] = b[i+j-1] + 2; @@ -27,4 +25,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-11.c b/gcc/testsuite/gcc.dg/graphite/scop-11.c index 4a7286993c5..97fe5393b37 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-11.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-11.c @@ -10,7 +10,6 @@ int toto() for (j = 0; j <= 20; j++) a[j] = b + i; b = 3; - bar(); } else { @@ -28,4 +27,4 @@ int toto() return a[b]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-12.c b/gcc/testsuite/gcc.dg/graphite/scop-12.c index 221d987bfba..68e12050488 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-12.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-12.c @@ -32,4 +32,4 @@ int toto() return a[b]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 5" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-13.c b/gcc/testsuite/gcc.dg/graphite/scop-13.c index 195b7569389..53a17196d3e 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-13.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-13.c @@ -37,4 +37,4 @@ int toto() return a[b]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-16.c b/gcc/testsuite/gcc.dg/graphite/scop-16.c index cacd564e9e5..676817014b2 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-16.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-16.c @@ -21,4 +21,4 @@ int test () foo (a[i][j]); } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-17.c b/gcc/testsuite/gcc.dg/graphite/scop-17.c index 2252766b796..3c0d8804549 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-17.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-17.c @@ -20,4 +20,4 @@ int test () foo (a[i][j]); } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-18.c b/gcc/testsuite/gcc.dg/graphite/scop-18.c index 6e1080bc701..3416304075d 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-18.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-18.c @@ -22,4 +22,4 @@ void test (void) A[i][j] = B[i][k] * C[k][j]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-2.c b/gcc/testsuite/gcc.dg/graphite/scop-2.c index a16717c600a..fb1a4e7b692 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-2.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-2.c @@ -35,4 +35,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 4" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-21.c b/gcc/testsuite/gcc.dg/graphite/scop-21.c index 48a6d2ff5a8..bd3f811d9d1 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-21.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-21.c @@ -5,6 +5,9 @@ int test () int a[N+6]; int i; + for (i = 0; i < N; i++) + a[i] += 32; + for (i = 0; i < N; i++) { a[i] = i + 12; diff --git a/gcc/testsuite/gcc.dg/graphite/scop-22.c b/gcc/testsuite/gcc.dg/graphite/scop-22.c index c936428b7bb..6ff5ccd5b56 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-22.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-22.c @@ -6,6 +6,9 @@ void foo(int N, int *res) double a, b; double sum = 0.0; + for (i = 0; i < N; i++) + sum += u[i]; + for (i = 0; i < N; i++) { a = u[i]; diff --git a/gcc/testsuite/gcc.dg/graphite/scop-4.c b/gcc/testsuite/gcc.dg/graphite/scop-4.c index c6d719e2dd0..4fb0e5ea471 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-4.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-4.c @@ -25,4 +25,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-5.c b/gcc/testsuite/gcc.dg/graphite/scop-5.c index fa1c64a0ca8..8309257554c 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-5.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-5.c @@ -9,6 +9,8 @@ int toto() { for (j = 0; j <= 20; j++) a[j] = b + i; + for (j = 2; j <= 23; j++) + a[j] = b + i; b = 3; bar(); } @@ -31,4 +33,4 @@ int toto() return a[b]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-6.c b/gcc/testsuite/gcc.dg/graphite/scop-6.c index 2a45d6ee559..1da486a2ddf 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-6.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-6.c @@ -17,7 +17,6 @@ int toto() { for (k = 1; k < 100; k++) b[i+k] = b[i+k-1] + 2; - bar (); } for (k = 1; k < 100; k++) @@ -27,4 +26,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-7.c b/gcc/testsuite/gcc.dg/graphite/scop-7.c index 5866ca736f6..3e337d0c603 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-7.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-7.c @@ -13,7 +13,6 @@ int toto() if (i * 2 == i + 8) { - bar (); for (j = 1; j < 100; j++) b[i+j] = b[i+j-1] + 2; } @@ -27,4 +26,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-8.c b/gcc/testsuite/gcc.dg/graphite/scop-8.c index 9cdc69f670d..71d5c531fb8 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-8.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-8.c @@ -14,8 +14,7 @@ int toto() if (i * 2 == i + 8) { for (j = 1; j < 100; j++) - if (bar ()) - b[i+j] = b[i+j-1] + 2; + b[i+j] = b[i+j-1] + 2; } else a[i][i] = 2; @@ -27,4 +26,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-9.c b/gcc/testsuite/gcc.dg/graphite/scop-9.c index d879d9afda3..93888728b0d 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-9.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-9.c @@ -12,8 +12,6 @@ int toto() b[i+j] = b[i+j-1] + 2; if (i * 2 == i + 8) - bar (); - else a[i][i] = 2; for (k = 1; k < 100; k++) @@ -23,4 +21,4 @@ int toto() return a[3][5] + b[1]; } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-mvt.c b/gcc/testsuite/gcc.dg/graphite/scop-mvt.c index 5d3d19f7413..442a3a0bafa 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-mvt.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-mvt.c @@ -8,16 +8,16 @@ void mvt(long N) { for (i=0; i *references) return clobbers_memory; } + +/* Returns true if the loop-nest has any data reference. */ + +bool +loop_nest_has_data_refs (loop_p loop) +{ + basic_block *bbs = get_loop_body (loop); + vec references; + references.create (3); + + for (unsigned i = 0; i < loop->num_nodes; i++) + { + basic_block bb = bbs[i]; + gimple_stmt_iterator bsi; + + for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + { + gimple stmt = gsi_stmt (bsi); + get_references_in_stmt (stmt, &references); + if (references.length ()) + { + free (bbs); + references.release (); + return true; + } + } + } + free (bbs); + references.release (); + + if (loop->inner) + { + loop = loop->inner; + while (loop) + { + if (loop_nest_has_data_refs (loop)) + return true; + loop = loop->next; + } + } + return false; +} + /* Stores the data references in STMT to DATAREFS. If there is an unanalyzable reference, returns false, otherwise returns true. NEST is the outermost loop of the loop nest in which the references should be analyzed. */ diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index 18bcc5c89bb..064843933f3 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -322,6 +322,7 @@ extern bool find_data_references_in_stmt (struct loop *, gimple, extern bool graphite_find_data_references_in_stmt (loop_p, loop_p, gimple, vec *); tree find_data_references_in_loop (struct loop *, vec *); +bool loop_nest_has_data_refs (loop_p loop); struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple, bool); extern bool find_loop_nest (struct loop *, vec *); extern struct data_dependence_relation *initialize_data_dependence_relation diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index a6bd73677a3..29665c226e1 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,14 @@ +2015-09-08 Aditya Kumar + Sebastian Pop + + * 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. + 2015-09-03 Jakub Jelinek * configure.tgt: Add missing ;; in between nvptx and rtems diff --git a/libgomp/testsuite/libgomp.graphite/bounds.c b/libgomp/testsuite/libgomp.graphite/bounds.c index 822eb6a6f95..3d2fd7aaec8 100644 --- a/libgomp/testsuite/libgomp.graphite/bounds.c +++ b/libgomp/testsuite/libgomp.graphite/bounds.c @@ -3,6 +3,8 @@ int foo(int *a, int n) int i; for (i = 2; i < n; i++) a[i] += a[i+1]; + for (i = 2; i < n; i++) + a[i] += a[i+1]; } /* Check that Graphite dependency checking notes the dependency. */ diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-1.c b/libgomp/testsuite/libgomp.graphite/force-parallel-1.c index 245e64c6271..0393356f9f2 100644 --- a/libgomp/testsuite/libgomp.graphite/force-parallel-1.c +++ b/libgomp/testsuite/libgomp.graphite/force-parallel-1.c @@ -6,6 +6,9 @@ void parloop (int N) { int i; + for (i = 0; i < N; i++) + x[i] = i + 1; + for (i = 0; i < N; i++) x[i] = i + 3; @@ -24,5 +27,5 @@ int main(void) } /* Check that parallel code generation part make the right answer. */ -/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */ -/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "loopfn" 8 "optimized" } } */ diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-4.c b/libgomp/testsuite/libgomp.graphite/force-parallel-4.c index 513d58d7391..b58883c377a 100644 --- a/libgomp/testsuite/libgomp.graphite/force-parallel-4.c +++ b/libgomp/testsuite/libgomp.graphite/force-parallel-4.c @@ -47,7 +47,6 @@ int main(void) } /* Check that parallel code generation part make the right answer. */ -/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "loopfn.0" 4 "optimized" } } */ /* { dg-final { scan-tree-dump-times "loopfn.1" 4 "optimized" } } */ diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-5.c b/libgomp/testsuite/libgomp.graphite/force-parallel-5.c index d5994677253..de31d6436f5 100644 --- a/libgomp/testsuite/libgomp.graphite/force-parallel-5.c +++ b/libgomp/testsuite/libgomp.graphite/force-parallel-5.c @@ -31,6 +31,6 @@ int main(void) } /* Check that parallel code generation part make the right answer. */ -/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "loopfn.0" 4 "optimized" } } */ /* { dg-final { scan-tree-dump-times "loopfn.1" 4 "optimized" } } */ diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-7.c b/libgomp/testsuite/libgomp.graphite/force-parallel-7.c index 5a54d474771..9d2b37cbd4b 100644 --- a/libgomp/testsuite/libgomp.graphite/force-parallel-7.c +++ b/libgomp/testsuite/libgomp.graphite/force-parallel-7.c @@ -31,5 +31,5 @@ int main (void) } /* Check that parallel code generation part make the right answer. */ -/* { dg-final { scan-tree-dump-times "3 loops carried no dependency" 1 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "5 loops carried no dependency" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "loopfn.0" 4 "optimized" } } */ diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-8.c b/libgomp/testsuite/libgomp.graphite/force-parallel-8.c index dc60f2f32b4..32ba5ab84ef 100644 --- a/libgomp/testsuite/libgomp.graphite/force-parallel-8.c +++ b/libgomp/testsuite/libgomp.graphite/force-parallel-8.c @@ -43,8 +43,6 @@ int main(void) } /* Check that parallel code generation part make the right answer. */ -/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */ -/* { dg-final { scan-tree-dump-times "3 loops carried no dependency" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "5 loops carried no dependency" 1 "graphite" } } */ /* { dg-final { scan-tree-dump-times "loopfn.0" 4 "optimized" } } */ /* { dg-final { scan-tree-dump-times "loopfn.1" 4 "optimized" } } */ -- 2.30.2