From: Aditya Kumar Date: Tue, 6 Oct 2015 15:56:03 +0000 (+0000) Subject: Move declarations, assign types, renaming. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e4dc590c8878aaae1cdf5db6cbf84f8546b6511;p=gcc.git Move declarations, assign types, renaming. 1. Move declarations near the assignment/usage. 2. Assign type to members which were void*. 3. Rename scop->context to scop::param_context, and scop::ctx to scop::isl_context No functional changes intended. Passes regtest and bootstrap. gcc/ChangeLog: 2015-10-05 Aditya Kumar * graphite-dependences.c (scop_get_reads): Renamed scop->context to scop->param_context. (scop_get_must_writes): Same. (scop_get_may_writes): Same. (scop_get_original_schedule): Same. (scop_get_transformed_schedule): Same. (subtract_commutative_associative_deps): Same. * graphite-isl-ast-to-gimple.c (add_parameters_to_ivs_params): Same. (generate_isl_context): Same. (generate_isl_schedule): Same. (scop_to_isl_ast): Same. (graphite_regenerate_ast_isl): Same. * graphite-optimize-isl.c (scop_get_domains): Same. (optimize_isl): Renamed scop->context to scop->param_context. * graphite-poly.c (new_poly_bb): Change the type of argument to gimple_poly_bb_p. (new_scop): Renamed scop->context to scop->param_context. (free_scop): Same. (print_scop_context): Same. * graphite-poly.h (new_poly_dr): Change the type of argument from void* to data_reference_p. (struct poly_bb): Change the type of black_box to gimple_poly_bb_p. (new_poly_bb): Change the type of argument from void* to gimple_poly_bb_p. (pbb_set_black_box): Same. (struct scop): Rename context to param_context, ctx to isl_context. * graphite-scop-detection.c (scop_detection::build_scop_bbs_1): Move declarations closer to assignment. (find_params_in_bb): Same. (find_scop_parameters): Same. * graphite-sese-to-poly.c (unsigned ssa_name_version_typesize): Global to be used for statement IDs. (isl_id_for_pbb): Use ssa_name_version_typesize. (simple_copy_phi_p): Move declarations closer to assignment. (build_pbb_scattering_polyhedrons): Same. (build_scop_scattering): Same. (isl_id_for_ssa_name): Same. (extract_affine_name): Same. (extract_affine_int): Same. (extract_affine): Same. (set_scop_parameter_dim): Use renamed member. (build_loop_iteration_domains): Same. (add_param_constraints): Same. (build_scop_iteration_domain): Same. (pdr_add_data_dimensions): Same. (build_poly_dr): Same. (build_scop_drs): Move declarations closer to assignment. (analyze_drs_in_stmts): Same. (insert_out_of_ssa_copy): Same. (insert_out_of_ssa_copy_on_edge): Same. (propagate_expr_outside_region): Same. (rewrite_phi_out_of_ssa): Same. (rewrite_degenerate_phi): Same. (rewrite_reductions_out_of_ssa): Same. (rewrite_cross_bb_scalar_dependence): Same. (handle_scalar_deps_crossing_scop_limits): Same. (rewrite_cross_bb_scalar_deps): Same. * graphite.c (graphite_transform_loops): Use renamed member. From-SVN: r228528 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 476e2ef64c1..08efe78faab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,64 @@ +2015-10-05 Aditya Kumar + + * graphite-dependences.c (scop_get_reads): Renamed scop->context + to scop->param_context. + (scop_get_must_writes): Same. + (scop_get_may_writes): Same. + (scop_get_original_schedule): Same. + (scop_get_transformed_schedule): Same. + (subtract_commutative_associative_deps): Same. + * graphite-isl-ast-to-gimple.c (add_parameters_to_ivs_params): Same. + (generate_isl_context): Same. + (generate_isl_schedule): Same. + (scop_to_isl_ast): Same. + (graphite_regenerate_ast_isl): Same. + * graphite-optimize-isl.c (scop_get_domains): Same. + (optimize_isl): Renamed scop->context to scop->param_context. + * graphite-poly.c (new_poly_bb): Change the type of argument to + gimple_poly_bb_p. + (new_scop): Renamed scop->context to scop->param_context. + (free_scop): Same. + (print_scop_context): Same. + * graphite-poly.h (new_poly_dr): Change the type of argument from + void* to data_reference_p. + (struct poly_bb): Change the type of black_box to gimple_poly_bb_p. + (new_poly_bb): Change the type of argument from void* to + gimple_poly_bb_p. + (pbb_set_black_box): Same. + (struct scop): Rename context to param_context, ctx to isl_context. + * graphite-scop-detection.c (scop_detection::build_scop_bbs_1): + Move declarations closer to assignment. + (find_params_in_bb): Same. + (find_scop_parameters): Same. + * graphite-sese-to-poly.c (unsigned ssa_name_version_typesize): + Global to be used for statement IDs. + (isl_id_for_pbb): Use ssa_name_version_typesize. + (simple_copy_phi_p): Move declarations closer to assignment. + (build_pbb_scattering_polyhedrons): Same. + (build_scop_scattering): Same. + (isl_id_for_ssa_name): Same. + (extract_affine_name): Same. + (extract_affine_int): Same. + (extract_affine): Same. + (set_scop_parameter_dim): Use renamed member. + (build_loop_iteration_domains): Same. + (add_param_constraints): Same. + (build_scop_iteration_domain): Same. + (pdr_add_data_dimensions): Same. + (build_poly_dr): Same. + (build_scop_drs): Move declarations closer to assignment. + (analyze_drs_in_stmts): Same. + (insert_out_of_ssa_copy): Same. + (insert_out_of_ssa_copy_on_edge): Same. + (propagate_expr_outside_region): Same. + (rewrite_phi_out_of_ssa): Same. + (rewrite_degenerate_phi): Same. + (rewrite_reductions_out_of_ssa): Same. + (rewrite_cross_bb_scalar_dependence): Same. + (handle_scalar_deps_crossing_scop_limits): Same. + (rewrite_cross_bb_scalar_deps): Same. + * graphite.c (graphite_transform_loops): Use renamed member. + 2015-10-06 Uros Bizjak PR c/65345 diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c index e39394a8053..4752133399f 100644 --- a/gcc/graphite-dependences.c +++ b/gcc/graphite-dependences.c @@ -79,7 +79,7 @@ scop_get_reads (scop_p scop, vec pbbs) int i, j; poly_bb_p pbb; poly_dr_p pdr; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_union_map *res = isl_union_map_empty (space); FOR_EACH_VEC_ELT (pbbs, i, pbb) @@ -100,7 +100,7 @@ scop_get_must_writes (scop_p scop, vec pbbs) int i, j; poly_bb_p pbb; poly_dr_p pdr; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_union_map *res = isl_union_map_empty (space); FOR_EACH_VEC_ELT (pbbs, i, pbb) @@ -121,7 +121,7 @@ scop_get_may_writes (scop_p scop, vec pbbs) int i, j; poly_bb_p pbb; poly_dr_p pdr; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_union_map *res = isl_union_map_empty (space); FOR_EACH_VEC_ELT (pbbs, i, pbb) @@ -141,7 +141,7 @@ scop_get_original_schedule (scop_p scop, vec pbbs) { int i; poly_bb_p pbb; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_union_map *res = isl_union_map_empty (space); FOR_EACH_VEC_ELT (pbbs, i, pbb) @@ -161,7 +161,7 @@ scop_get_transformed_schedule (scop_p scop, vec pbbs) { int i; poly_bb_p pbb; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_union_map *res = isl_union_map_empty (space); FOR_EACH_VEC_ELT (pbbs, i, pbb) @@ -356,7 +356,7 @@ subtract_commutative_associative_deps (scop_p scop, int i, j; poly_bb_p pbb; poly_dr_p pdr; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); FOR_EACH_VEC_ELT (pbbs, i, pbb) if (PBB_IS_REDUCTION (pbb)) diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index 18342d02ecf..43cb7ddfe3c 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -911,12 +911,13 @@ static void add_parameters_to_ivs_params (scop_p scop, ivs_params &ip) { sese region = SCOP_REGION (scop); - unsigned nb_parameters = isl_set_dim (scop->context, isl_dim_param); + unsigned nb_parameters = isl_set_dim (scop->param_context, isl_dim_param); gcc_assert (nb_parameters == SESE_PARAMS (region).length ()); unsigned i; for (i = 0; i < nb_parameters; i++) { - isl_id *tmp_id = isl_set_get_dim_id (scop->context, isl_dim_param, i); + isl_id *tmp_id = isl_set_get_dim_id (scop->param_context, + isl_dim_param, i); ip[tmp_id] = SESE_PARAMS (region)[i]; } } @@ -927,7 +928,7 @@ add_parameters_to_ivs_params (scop_p scop, ivs_params &ip) static __isl_give isl_ast_build * generate_isl_context (scop_p scop) { - isl_set *context_isl = isl_set_params (isl_set_copy (scop->context)); + isl_set *context_isl = isl_set_params (isl_set_copy (scop->param_context)); return isl_ast_build_from_context (context_isl); } @@ -985,7 +986,7 @@ generate_isl_schedule (scop_p scop) int i; poly_bb_p pbb; isl_union_map *schedule_isl = - isl_union_map_empty (isl_set_get_space (scop->context)); + isl_union_map_empty (isl_set_get_space (scop->param_context)); FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb) { @@ -1048,7 +1049,7 @@ scop_to_isl_ast (scop_p scop, ivs_params &ip) an operator (< or <=) and an expression not involving the iterator. If this option is not set, then the current loop iterator may appear several times in the upper bound. See the isl manual for more details. */ - isl_options_set_ast_build_atomic_upper_bound (scop->ctx, true); + isl_options_set_ast_build_atomic_upper_bound (scop->isl_context, true); add_parameters_to_ivs_params (scop, ip); isl_union_map *schedule_isl = generate_isl_schedule (scop); @@ -1155,7 +1156,7 @@ graphite_regenerate_ast_isl (scop_p scop) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "\nISL AST generated by ISL: \n"); - print_isl_ast_node (dump_file, root_node, scop->ctx); + print_isl_ast_node (dump_file, root_node, scop->isl_context); fprintf (dump_file, "\n"); } diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c index 512c64c3db3..3fe313374ad 100644 --- a/gcc/graphite-optimize-isl.c +++ b/gcc/graphite-optimize-isl.c @@ -55,7 +55,7 @@ scop_get_domains (scop_p scop ATTRIBUTE_UNUSED) { int i; poly_bb_p pbb; - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_union_set *res = isl_union_set_empty (space); FOR_EACH_VEC_ELT (scop->bbs, i, pbb) @@ -294,12 +294,12 @@ bool optimize_isl (scop_p scop) { #ifdef HAVE_ISL_CTX_MAX_OPERATIONS - int old_max_operations = isl_ctx_get_max_operations (scop->ctx); + int old_max_operations = isl_ctx_get_max_operations (scop->isl_context); int max_operations = PARAM_VALUE (PARAM_MAX_ISL_OPERATIONS); if (max_operations) - isl_ctx_set_max_operations (scop->ctx, max_operations); + isl_ctx_set_max_operations (scop->isl_context, max_operations); #endif - isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_CONTINUE); + isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_CONTINUE); isl_union_set *domain = scop_get_domains (scop); isl_union_map *dependences = scop_get_dependences (scop); @@ -324,11 +324,11 @@ optimize_isl (scop_p scop) validity); #endif - isl_options_set_schedule_max_constant_term (scop->ctx, CONSTANT_BOUND); - isl_options_set_schedule_maximize_band_depth (scop->ctx, 1); + isl_options_set_schedule_max_constant_term (scop->isl_context, CONSTANT_BOUND); + isl_options_set_schedule_maximize_band_depth (scop->isl_context, 1); #ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS /* ISL-0.15 or later. */ - isl_options_set_schedule_serialize_sccs (scop->ctx, 1); + isl_options_set_schedule_serialize_sccs (scop->isl_context, 1); #else isl_options_set_schedule_fuse (scop->ctx, ISL_SCHEDULE_FUSE_MIN); #endif @@ -341,12 +341,12 @@ optimize_isl (scop_p scop) = isl_union_set_compute_schedule (domain, validity, proximity); #endif - isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_ABORT); + isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_ABORT); #ifdef HAVE_ISL_CTX_MAX_OPERATIONS - isl_ctx_reset_operations (scop->ctx); - isl_ctx_set_max_operations (scop->ctx, old_max_operations); - if (!schedule || isl_ctx_last_error (scop->ctx) == isl_error_quota) + isl_ctx_reset_operations (scop->isl_context); + isl_ctx_set_max_operations (scop->isl_context, old_max_operations); + if (!schedule || isl_ctx_last_error (scop->isl_context) == isl_error_quota) { if (dump_file && dump_flags) fprintf (dump_file, "ISL timed out at %d operations\n", diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index ce1a18fbd21..5d6a669e2d2 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -137,7 +137,7 @@ apply_poly_transforms (scop_p scop) void new_poly_dr (poly_bb_p pbb, int dr_base_object_set, - enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts, + enum poly_dr_type type, data_reference_p cdr, graphite_dim_t nb_subscripts, isl_map *acc, isl_set *subscript_sizes) { static int id = 0; @@ -168,7 +168,7 @@ free_poly_dr (poly_dr_p pdr) /* Create a new polyhedral black box. */ poly_bb_p -new_poly_bb (scop_p scop, void *black_box) +new_poly_bb (scop_p scop, gimple_poly_bb_p black_box) { poly_bb_p pbb = XNEW (struct poly_bb); @@ -325,7 +325,7 @@ new_scop (edge entry, edge exit) sese region = new_sese (entry, exit); scop_p scop = XNEW (struct scop); - scop->context = NULL; + scop->param_context = NULL; scop->must_raw = NULL; scop->may_raw = NULL; scop->must_raw_no_source = NULL; @@ -361,7 +361,7 @@ free_scop (scop_p scop) SCOP_BBS (scop).release (); - isl_set_free (scop->context); + isl_set_free (scop->param_context); isl_union_map_free (scop->must_raw); isl_union_map_free (scop->may_raw); isl_union_map_free (scop->must_raw_no_source); @@ -620,8 +620,8 @@ print_scop_context (FILE *file, scop_p scop, int verbosity) if (verbosity > 0) fprintf (file, "# Context (\n"); - if (scop->context) - print_isl_set (file, scop->context); + if (scop->param_context) + print_isl_set (file, scop->param_context); if (verbosity > 0) fprintf (file, "# )\n"); diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h index c404b421aa0..3618b662821 100644 --- a/gcc/graphite-poly.h +++ b/gcc/graphite-poly.h @@ -59,7 +59,7 @@ struct poly_dr int nb_refs; /* A pointer to compiler's data reference description. */ - void *compiler_dr; + data_reference_p compiler_dr; /* A pointer to the PBB that contains this data reference. */ poly_bb_p pbb; @@ -199,7 +199,7 @@ struct poly_dr #define PDR_BASE_OBJECT_SET(PDR) (PDR->dr_base_object_set) #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts) -void new_poly_dr (poly_bb_p, int, enum poly_dr_type, void *, +void new_poly_dr (poly_bb_p, int, enum poly_dr_type, data_reference_p, graphite_dim_t, isl_map *, isl_set *); void free_poly_dr (poly_dr_p); void debug_pdr (poly_dr_p, int); @@ -232,7 +232,7 @@ pdr_may_write_p (poly_dr_p pdr) struct poly_bb { /* Pointer to a basic block or a statement in the compiler. */ - void *black_box; + gimple_poly_bb_p black_box; /* Pointer to the SCOP containing this PBB. */ scop_p scop; @@ -282,7 +282,7 @@ struct poly_bb #define PBB_DRS(PBB) (PBB->drs) #define PBB_IS_REDUCTION(PBB) (PBB->is_reduction) -extern poly_bb_p new_poly_bb (scop_p, void *); +extern poly_bb_p new_poly_bb (scop_p, gimple_poly_bb_p); extern void free_poly_bb (poly_bb_p); extern void debug_loop_vec (poly_bb_p); extern void print_pbb_domain (FILE *, poly_bb_p, int); @@ -366,7 +366,7 @@ pdr_scop (poly_dr_p pdr) /* Set black box of PBB to BLACKBOX. */ static inline void -pbb_set_black_box (poly_bb_p pbb, void *black_box) +pbb_set_black_box (poly_bb_p pbb, gimple_poly_bb_p black_box) { pbb->black_box = black_box; } @@ -399,10 +399,10 @@ struct scop -128 >= a >= 127 0 >= b >= 65,535 c = 2a + b */ - isl_set *context; + isl_set *param_context; /* The context used internally by ISL. */ - isl_ctx *ctx; + isl_ctx *isl_context; /* The original dependence relations: RAW are read after write dependences, diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index cd8e4d56082..4b04315e8a0 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -1610,17 +1610,15 @@ void scop_detection::build_scop_bbs_1 (scop_p scop, sbitmap visited, basic_block bb) { sese region = SCOP_REGION (scop); - vec dom; - poly_bb_p pbb; if (bitmap_bit_p (visited, bb->index) || !bb_in_sese_p (bb, region)) return; - pbb = new_poly_bb (scop, try_generate_gimple_bb (scop, bb)); + poly_bb_p pbb = new_poly_bb (scop, try_generate_gimple_bb (scop, bb)); SCOP_BBS (scop).safe_push (pbb); bitmap_set_bit (visited, bb->index); - dom = get_dominated_by (CDI_DOMINATORS, bb); + vec dom = get_dominated_by (CDI_DOMINATORS, bb); if (!dom.exists ()) return; @@ -1781,18 +1779,16 @@ scan_tree_for_params (sese s, tree e) static void find_params_in_bb (sese region, gimple_poly_bb_p gbb) { + /* Find parameters in the access functions of data references. */ int i; - unsigned j; data_reference_p dr; - gimple *stmt; - loop_p loop = GBB_BB (gbb)->loop_father; - - /* Find parameters in the access functions of data references. */ FOR_EACH_VEC_ELT (GBB_DATA_REFS (gbb), i, dr) - for (j = 0; j < DR_NUM_DIMENSIONS (dr); j++) + for (unsigned j = 0; j < DR_NUM_DIMENSIONS (dr); j++) scan_tree_for_params (region, DR_ACCESS_FN (dr, j)); /* Find parameters in conditional statements. */ + gimple *stmt; + loop_p loop = GBB_BB (gbb)->loop_father; FOR_EACH_VEC_ELT (GBB_CONDITIONS (gbb), i, stmt) { tree lhs = scalar_evolution_in_region (region, loop, @@ -1811,11 +1807,9 @@ find_params_in_bb (sese region, gimple_poly_bb_p gbb) static void find_scop_parameters (scop_p scop) { - poly_bb_p pbb; unsigned i; sese region = SCOP_REGION (scop); struct loop *loop; - int nbp; /* Find the parameters used in the loop bounds. */ FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region), i, loop) @@ -1830,10 +1824,11 @@ find_scop_parameters (scop_p scop) } /* Find the parameters used in data accesses. */ + poly_bb_p pbb; FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb) find_params_in_bb (region, PBB_BLACK_BOX (pbb)); - nbp = sese_nb_params (region); + int nbp = sese_nb_params (region); scop_set_nb_params (scop, nbp); SESE_ADD_PARAMS (region) = false; } diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index af9fa659db0..15d16c1a488 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -68,6 +68,8 @@ extern "C" { #include "graphite-sese-to-poly.h" +static const unsigned ssa_name_version_typesize = sizeof(unsigned); + /* Assigns to RES the value of the INTEGER_CST T. */ static inline void @@ -146,12 +148,10 @@ remove_invariant_phi (sese region, gphi_iterator *psi) static inline bool simple_copy_phi_p (gphi *phi) { - tree res; - if (gimple_phi_num_args (phi) != 2) return false; - res = gimple_phi_result (phi); + tree res = gimple_phi_result (phi); return (res == gimple_phi_arg_def (phi, 0) || res == gimple_phi_arg_def (phi, 1)); } @@ -201,9 +201,9 @@ reduction_phi_p (sese region, gphi_iterator *psi) static isl_id * isl_id_for_pbb (scop_p s, poly_bb_p pbb) { - char name[50]; + char name[ssa_name_version_typesize]; snprintf (name, sizeof (name), "S_%d", pbb_index (pbb)); - return isl_id_alloc (s->ctx, name, pbb); + return isl_id_alloc (s->isl_context, name, pbb); } /* Converts the STATIC_SCHEDULE of PBB into a scattering polyhedron. @@ -237,18 +237,16 @@ static void build_pbb_scattering_polyhedrons (isl_aff *static_sched, poly_bb_p pbb) { - int i; isl_val *val; - isl_space *dc, *dm; int scattering_dimensions = isl_set_dim (pbb->domain, isl_dim_set) * 2 + 1; - dc = isl_set_get_space (pbb->domain); - dm = isl_space_add_dims (isl_space_from_domain (dc), - isl_dim_out, scattering_dimensions); + isl_space *dc = isl_set_get_space (pbb->domain); + isl_space *dm = isl_space_add_dims (isl_space_from_domain (dc), + isl_dim_out, scattering_dimensions); pbb->schedule = isl_map_universe (dm); - for (i = 0; i < scattering_dimensions; i++) + for (int i = 0; i < scattering_dimensions; i++) { /* Textual order inside this loop. */ if ((i % 2) == 0) @@ -316,10 +314,8 @@ build_pbb_scattering_polyhedrons (isl_aff *static_sched, static void build_scop_scattering (scop_p scop) { - int i; - poly_bb_p pbb; gimple_poly_bb_p previous_gbb = NULL; - isl_space *dc = isl_set_get_space (scop->context); + isl_space *dc = isl_set_get_space (scop->param_context); isl_aff *static_sched; dc = isl_space_add_dims (dc, isl_dim_set, number_of_loops (cfun)); @@ -331,15 +327,15 @@ build_scop_scattering (scop_p scop) incremented before copying. */ static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_in, 0, -1); + int i; + poly_bb_p pbb; FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb) { gimple_poly_bb_p gbb = PBB_BLACK_BOX (pbb); - int prefix; + int prefix = 0; if (previous_gbb) prefix = nb_common_loops (SCOP_REGION (scop), previous_gbb, gbb); - else - prefix = 0; previous_gbb = gbb; @@ -402,12 +398,12 @@ isl_id_for_ssa_name (scop_p s, tree e) isl_id *id; if (name) - id = isl_id_alloc (s->ctx, name, e); + id = isl_id_alloc (s->isl_context, name, e); else { - char name1[50]; + char name1[ssa_name_version_typesize]; snprintf (name1, sizeof (name1), "P_%d", SSA_NAME_VERSION (e)); - id = isl_id_alloc (s->ctx, name1, e); + id = isl_id_alloc (s->isl_context, name1, e); } return id; @@ -421,7 +417,7 @@ isl_id_for_dr (scop_p s, data_reference_p dr ATTRIBUTE_UNUSED) /* Data references all get the same isl_id. They need to be comparable and are distinguished through the first dimension, which contains the alias set number. */ - return isl_id_alloc (s->ctx, "", 0); + return isl_id_alloc (s->isl_context, "", 0); } /* Extract an affine expression from the ssa_name E. */ @@ -429,16 +425,11 @@ isl_id_for_dr (scop_p s, data_reference_p dr ATTRIBUTE_UNUSED) static isl_pw_aff * extract_affine_name (scop_p s, tree e, __isl_take isl_space *space) { - isl_aff *aff; - isl_set *dom; - isl_id *id; - int dimension; - - id = isl_id_for_ssa_name (s, e); - dimension = isl_space_find_dim_by_id (space, isl_dim_param, id); + isl_id *id = isl_id_for_ssa_name (s, e); + int dimension = isl_space_find_dim_by_id (space, isl_dim_param, id); isl_id_free (id); - dom = isl_set_universe (isl_space_copy (space)); - aff = isl_aff_zero_on_domain (isl_local_space_from_space (space)); + isl_set *dom = isl_set_universe (isl_space_copy (space)); + isl_aff *aff = isl_aff_zero_on_domain (isl_local_space_from_space (space)); aff = isl_aff_add_coefficient_si (aff, isl_dim_param, dimension, 1); return isl_pw_aff_alloc (dom, aff); } @@ -451,11 +442,8 @@ extract_affine_gmp (mpz_t g, __isl_take isl_space *space) isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space)); isl_aff *aff = isl_aff_zero_on_domain (ls); isl_set *dom = isl_set_universe (space); - isl_val *v; - isl_ctx *ct; - - ct = isl_aff_get_ctx (aff); - v = isl_val_int_from_gmp (ct, g); + isl_ctx *ct = isl_aff_get_ctx (aff); + isl_val *v = isl_val_int_from_gmp (ct, g); aff = isl_aff_add_constant_val (aff, v); return isl_pw_aff_alloc (dom, aff); @@ -466,12 +454,11 @@ extract_affine_gmp (mpz_t g, __isl_take isl_space *space) static isl_pw_aff * extract_affine_int (tree e, __isl_take isl_space *space) { - isl_pw_aff *res; mpz_t g; mpz_init (g); tree_int_to_gmp (e, g); - res = extract_affine_gmp (g, space); + isl_pw_aff *res = extract_affine_gmp (g, space); mpz_clear (g); return res; @@ -515,7 +502,6 @@ static isl_pw_aff * extract_affine (scop_p s, tree e, __isl_take isl_space *space) { isl_pw_aff *lhs, *rhs, *res; - tree type; if (e == chrec_dont_know) { isl_space_free (space); @@ -573,7 +559,7 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) break; } - type = TREE_TYPE (e); + tree type = TREE_TYPE (e); if (TYPE_UNSIGNED (type)) res = wrap (res, TYPE_PRECISION (type)); @@ -587,7 +573,7 @@ set_scop_parameter_dim (scop_p scop) { sese region = SCOP_REGION (scop); unsigned nbp = sese_nb_params (region); - isl_space *space = isl_space_set_alloc (scop->ctx, nbp, 0); + isl_space *space = isl_space_set_alloc (scop->isl_context, nbp, 0); unsigned i; tree e; @@ -595,7 +581,7 @@ set_scop_parameter_dim (scop_p scop) space = isl_space_set_dim_id (space, isl_dim_param, i, isl_id_for_ssa_name (scop, e)); - scop->context = isl_set_universe (space); + scop->param_context = isl_set_universe (space); } /* Builds the constraint polyhedra for LOOP in SCOP. OUTER_PH gives @@ -606,12 +592,11 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, int nb, isl_set *outer, isl_set **doms) { + tree nb_iters = number_of_latch_executions (loop); sese region = SCOP_REGION (scop); isl_set *inner = isl_set_copy (outer); - isl_space *space; - isl_constraint *c; int pos = isl_set_dim (outer, isl_dim_set); isl_val *v; mpz_t g; @@ -619,10 +604,10 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, mpz_init (g); inner = isl_set_add_dims (inner, isl_dim_set, 1); - space = isl_set_get_space (inner); + isl_space *space = isl_set_get_space (inner); /* 0 <= loop_i */ - c = isl_inequality_alloc + isl_constraint *c = isl_inequality_alloc (isl_local_space_from_space (isl_space_copy (space))); c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, 1); inner = isl_set_add_constraint (inner, c); @@ -634,7 +619,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, (isl_local_space_from_space (isl_space_copy (space))); c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1); tree_int_to_gmp (nb_iters, g); - v = isl_val_int_from_gmp (scop->ctx, g); + v = isl_val_int_from_gmp (scop->isl_context, g); c = isl_constraint_set_constant_val (c, v); inner = isl_set_add_constraint (inner, c); } @@ -642,28 +627,24 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, /* loop_i <= expr_nb_iters */ else if (!chrec_contains_undetermined (nb_iters)) { - widest_int nit; isl_pw_aff *aff; - isl_set *valid; - isl_local_space *ls; - isl_aff *al; - isl_set *le; nb_iters = scalar_evolution_in_region (region, loop, nb_iters); aff = extract_affine (scop, nb_iters, isl_set_get_space (inner)); - valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)); + isl_set *valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)); valid = isl_set_project_out (valid, isl_dim_set, 0, isl_set_dim (valid, isl_dim_set)); - scop->context = isl_set_intersect (scop->context, valid); + scop->param_context = isl_set_intersect (scop->param_context, valid); - ls = isl_local_space_from_space (isl_space_copy (space)); - al = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls), - isl_dim_in, pos, 1); - le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al), - isl_pw_aff_copy (aff)); + isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space)); + isl_aff *al = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls), + isl_dim_in, pos, 1); + isl_set *le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al), + isl_pw_aff_copy (aff)); inner = isl_set_intersect (inner, le); + widest_int nit; if (max_stmt_executions (loop, &nit)) { /* Insert in the context the constraints from the @@ -672,24 +653,22 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, names) NB_ITERS. First, build the affine expression "NIT - NB_ITERS" and then say that it is positive, i.e., NIT approximates NB_ITERS: "NIT >= NB_ITERS". */ - isl_pw_aff *approx; mpz_t g; - isl_set *x; - isl_constraint *c; - mpz_init (g); wi::to_mpz (nit, g, SIGNED); mpz_sub_ui (g, g, 1); - approx = extract_affine_gmp (g, isl_set_get_space (inner)); - x = isl_pw_aff_ge_set (approx, aff); + + isl_pw_aff *approx + = extract_affine_gmp (g, isl_set_get_space (inner)); + isl_set *x = isl_pw_aff_ge_set (approx, aff); x = isl_set_project_out (x, isl_dim_set, 0, isl_set_dim (x, isl_dim_set)); - scop->context = isl_set_intersect (scop->context, x); + scop->param_context = isl_set_intersect (scop->param_context, x); - c = isl_inequality_alloc + isl_constraint *c = isl_inequality_alloc (isl_local_space_from_space (isl_space_copy (space))); c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1); - v = isl_val_int_from_gmp (scop->ctx, g); + v = isl_val_int_from_gmp (scop->isl_context, g); mpz_clear (g); c = isl_constraint_set_constant_val (c, v); inner = isl_set_add_constraint (inner, c); @@ -855,7 +834,7 @@ add_param_constraints (scop_p scop, graphite_dim_t p) if (lb) { - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_constraint *c; mpz_t g; isl_val *v; @@ -863,18 +842,18 @@ add_param_constraints (scop_p scop, graphite_dim_t p) c = isl_inequality_alloc (isl_local_space_from_space (space)); mpz_init (g); tree_int_to_gmp (lb, g); - v = isl_val_int_from_gmp (scop->ctx, g); + v = isl_val_int_from_gmp (scop->isl_context, g); v = isl_val_neg (v); mpz_clear (g); c = isl_constraint_set_constant_val (c, v); c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, 1); - scop->context = isl_set_add_constraint (scop->context, c); + scop->param_context = isl_set_add_constraint (scop->param_context, c); } if (ub) { - isl_space *space = isl_set_get_space (scop->context); + isl_space *space = isl_set_get_space (scop->param_context); isl_constraint *c; mpz_t g; isl_val *v; @@ -883,12 +862,12 @@ add_param_constraints (scop_p scop, graphite_dim_t p) mpz_init (g); tree_int_to_gmp (ub, g); - v = isl_val_int_from_gmp (scop->ctx, g); + v = isl_val_int_from_gmp (scop->isl_context, g); mpz_clear (g); c = isl_constraint_set_constant_val (c, v); c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, -1); - scop->context = isl_set_add_constraint (scop->context, c); + scop->param_context = isl_set_add_constraint (scop->param_context, c); } } @@ -912,18 +891,18 @@ build_scop_context (scop_p scop) static void build_scop_iteration_domain (scop_p scop) { - struct loop *loop; sese region = SCOP_REGION (scop); - int i; - poly_bb_p pbb; int nb_loops = number_of_loops (cfun); isl_set **doms = XCNEWVEC (isl_set *, nb_loops); + int i; + struct loop *loop; FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region), i, loop) if (!loop_in_sese_p (loop_outer (loop), region)) build_loop_iteration_domains (scop, loop, 0, - isl_set_copy (scop->context), doms); + isl_set_copy (scop->param_context), doms); + poly_bb_p pbb; FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb) { loop = pbb_loop (pbb); @@ -931,13 +910,13 @@ build_scop_iteration_domain (scop_p scop) if (doms[loop->num]) pbb->domain = isl_set_copy (doms[loop->num]); else - pbb->domain = isl_set_copy (scop->context); + pbb->domain = isl_set_copy (scop->param_context); pbb->domain = isl_set_set_tuple_id (pbb->domain, isl_id_for_pbb (scop, pbb)); } - for (i = 0; i < nb_loops; i++) + for (int i = 0; i < nb_loops; i++) if (doms[i]) isl_set_free (doms[i]); @@ -1058,7 +1037,7 @@ pdr_add_data_dimensions (isl_set *subscript_sizes, scop_p scop, valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub)); valid = isl_set_project_out (valid, isl_dim_set, 0, isl_set_dim (valid, isl_dim_set)); - scop->context = isl_set_intersect (scop->context, valid); + scop->param_context = isl_set_intersect (scop->param_context, valid); aff = isl_aff_zero_on_domain (isl_local_space_from_space (space)); aff = isl_aff_add_coefficient_si (aff, isl_dim_in, i + 1, 1); @@ -1106,7 +1085,7 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb) { isl_id *id = isl_id_for_dr (scop, dr); int nb = 1 + DR_NUM_DIMENSIONS (dr); - isl_space *space = isl_space_set_alloc (scop->ctx, 0, nb); + isl_space *space = isl_space_set_alloc (scop->isl_context, 0, nb); int alias_set_num = 0; base_alias_pair *bap = (base_alias_pair *)(dr->aux); @@ -1411,8 +1390,6 @@ build_scop_drs (scop_p scop) { int i, j; poly_bb_p pbb; - data_reference_p dr; - auto_vec drs; /* Remove all the PBBs that do not have data references: these basic blocks are not handled in the polyhedral representation. */ @@ -1425,6 +1402,8 @@ build_scop_drs (scop_p scop) i--; } + data_reference_p dr; + auto_vec drs; FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb) for (j = 0; GBB_DATA_REFS (PBB_BLACK_BOX (pbb)).iterate (j, &dr); j++) drs.safe_push (dr); @@ -1457,23 +1436,19 @@ build_scop_drs (scop_p scop) static void analyze_drs_in_stmts (scop_p scop, basic_block bb, vec stmts) { - loop_p nest; - gimple_poly_bb_p gbb; - gimple *stmt; - int i; sese region = SCOP_REGION (scop); - if (!bb_in_sese_p (bb, region)) return; - nest = outermost_loop_in_sese (region, bb); - + loop_p nest = outermost_loop_in_sese (region, bb); loop_p loop = bb->loop_father; if (!loop_in_sese_p (loop, region)) loop = nest; - gbb = gbb_from_bb (bb); + gimple_poly_bb_p gbb = gbb_from_bb (bb); + gimple *stmt; + int i; FOR_EACH_VEC_ELT (stmts, i, stmt) { if (is_gimple_debug (stmt)) @@ -1508,13 +1483,14 @@ insert_stmts (scop_p scop, gimple *stmt, gimple_seq stmts, static void insert_out_of_ssa_copy (scop_p scop, tree res, tree expr, gimple *after_stmt) { - gimple_seq stmts; gimple_stmt_iterator gsi; + auto_vec x; + gimple_seq stmts; tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE); gassign *stmt = gimple_build_assign (unshare_expr (res), var); - auto_vec x; gimple_seq_add_stmt (&stmts, stmt); + for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) x.safe_push (gsi_stmt (gsi)); @@ -1564,20 +1540,19 @@ new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb) static void insert_out_of_ssa_copy_on_edge (scop_p scop, edge e, tree res, tree expr) { - gimple_stmt_iterator gsi; gimple_seq stmts = NULL; tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE); gimple *stmt = gimple_build_assign (unshare_expr (res), var); - basic_block bb; auto_vec x; gimple_seq_add_stmt (&stmts, stmt); + gimple_stmt_iterator gsi; for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi)) x.safe_push (gsi_stmt (gsi)); gsi_insert_seq_on_edge (e, stmts); gsi_commit_edge_inserts (); - bb = gimple_bb (stmt); + basic_block bb = gimple_bb (stmt); if (!bb_in_sese_p (bb, SCOP_REGION (scop))) return; @@ -1623,8 +1598,6 @@ scalar_close_phi_node_p (gimple *phi) static void propagate_expr_outside_region (tree def, tree expr, sese region) { - imm_use_iterator imm_iter; - gimple *use_stmt; gimple_seq stmts; bool replaced_once = false; @@ -1633,6 +1606,8 @@ propagate_expr_outside_region (tree def, tree expr, sese region) expr = force_gimple_operand (unshare_expr (expr), &stmts, true, NULL_TREE); + imm_use_iterator imm_iter; + gimple *use_stmt; FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) if (!is_gimple_debug (use_stmt) && !bb_in_sese_p (gimple_bb (use_stmt), region)) @@ -1742,14 +1717,12 @@ rewrite_close_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi) static void rewrite_phi_out_of_ssa (scop_p scop, gphi_iterator *psi) { - size_t i; gphi *phi = psi->phi (); basic_block bb = gimple_bb (phi); tree res = gimple_phi_result (phi); tree zero_dim_array = create_zero_dim_array (res, "phi_out_of_ssa"); - gimple *stmt; - for (i = 0; i < gimple_phi_num_args (phi); i++) + for (size_t i = 0; i < gimple_phi_num_args (phi); i++) { tree arg = gimple_phi_arg_def (phi, i); edge e = gimple_phi_arg_edge (phi, i); @@ -1765,7 +1738,7 @@ rewrite_phi_out_of_ssa (scop_p scop, gphi_iterator *psi) insert_out_of_ssa_copy_on_edge (scop, e, zero_dim_array, arg); } - stmt = gimple_build_assign (res, unshare_expr (zero_dim_array)); + gimple *stmt = gimple_build_assign (res, unshare_expr (zero_dim_array)); remove_phi_node (psi, false); insert_stmts (scop, stmt, NULL, gsi_after_labels (bb)); } @@ -1776,21 +1749,17 @@ rewrite_phi_out_of_ssa (scop_p scop, gphi_iterator *psi) static void rewrite_degenerate_phi (gphi_iterator *psi) { - tree rhs; - gimple *stmt; - gimple_stmt_iterator gsi; gphi *phi = psi->phi (); tree res = gimple_phi_result (phi); - basic_block bb; - bb = gimple_bb (phi); - rhs = degenerate_phi_result (phi); + basic_block bb = gimple_bb (phi); + tree rhs = degenerate_phi_result (phi); gcc_assert (rhs); - stmt = gimple_build_assign (res, rhs); + gimple *stmt = gimple_build_assign (res, rhs); remove_phi_node (psi, false); - gsi = gsi_after_labels (bb); + gimple_stmt_iterator gsi = gsi_after_labels (bb); gsi_insert_before (&gsi, stmt, GSI_NEW_STMT); } @@ -1800,12 +1769,11 @@ static void rewrite_reductions_out_of_ssa (scop_p scop) { basic_block bb; - gphi_iterator psi; sese region = SCOP_REGION (scop); FOR_EACH_BB_FN (bb, cfun) if (bb_in_sese_p (bb, region)) - for (psi = gsi_start_phis (bb); !gsi_end_p (psi);) + for (gphi_iterator psi = gsi_start_phis (bb); !gsi_end_p (psi);) { gphi *phi = psi.phi (); @@ -1839,19 +1807,16 @@ static void rewrite_cross_bb_scalar_dependence (scop_p scop, tree zero_dim_array, tree def, gimple *use_stmt) { - gimple *name_stmt; - tree name; - ssa_op_iter iter; - use_operand_p use_p; - gcc_assert (gimple_code (use_stmt) != GIMPLE_PHI); - name = copy_ssa_name (def); - name_stmt = gimple_build_assign (name, zero_dim_array); + tree name = copy_ssa_name (def); + gimple *name_stmt = gimple_build_assign (name, zero_dim_array); gimple_assign_set_lhs (name_stmt, name); insert_stmts (scop, name_stmt, NULL, gsi_for_stmt (use_stmt)); + ssa_op_iter iter; + use_operand_p use_p; FOR_EACH_SSA_USE_OPERAND (use_p, use_stmt, iter, SSA_OP_ALL_USES) if (operand_equal_p (def, USE_FROM_PTR (use_p), 0)) replace_exp (use_p, name); @@ -1869,15 +1834,15 @@ handle_scalar_deps_crossing_scop_limits (scop_p scop, tree def, gimple *stmt) tree var = create_tmp_reg (TREE_TYPE (def)); tree new_name = make_ssa_name (var, stmt); bool needs_copy = false; - use_operand_p use_p; - imm_use_iterator imm_iter; - gimple *use_stmt; sese region = SCOP_REGION (scop); + imm_use_iterator imm_iter; + gimple *use_stmt; FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) { if (!bb_in_sese_p (gimple_bb (use_stmt), region)) { + use_operand_p use_p; FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) { SET_USE (use_p, new_name); @@ -1911,7 +1876,6 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi) gimple *stmt = gsi_stmt (*gsi); imm_use_iterator imm_iter; tree def; - basic_block def_bb; tree zero_dim_array = NULL_TREE; gimple *use_stmt; bool res = false; @@ -1946,7 +1910,7 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi) return true; } - def_bb = gimple_bb (stmt); + basic_block def_bb = gimple_bb (stmt); handle_scalar_deps_crossing_scop_limits (scop, def, stmt); diff --git a/gcc/graphite.c b/gcc/graphite.c index 1188c243b1c..3d02b8f1f1b 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -328,7 +328,7 @@ graphite_transform_loops (void) FOR_EACH_VEC_ELT (scops, i, scop) if (dbg_cnt (graphite_scop)) { - scop->ctx = ctx; + scop->isl_context = ctx; build_poly_scop (scop); if (dump_file && dump_flags)