From 1a8821c54a5ff570e5d6005924ab9a165090d1cd Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 13 Oct 2017 10:40:42 +0000 Subject: [PATCH] graphite-isl-ast-to-gimple.c (max_mode_int_precision, [...]): Avoid global constructor by moving ... 2017-10-13 Richard Biener * graphite-isl-ast-to-gimple.c (max_mode_int_precision, graphite_expression_type_precision): Avoid global constructor by moving ... (translate_isl_ast_to_gimple::translate_isl_ast_to_gimple): Here. (translate_isl_ast_to_gimple::graphite_expr_type): Add type member. (translate_isl_ast_to_gimple::translate_isl_ast_node_for): Use it. (translate_isl_ast_to_gimple::build_iv_mapping): Likewise. (translate_isl_ast_to_gimple::graphite_create_new_guard): Likewise. * graphite-sese-to-poly.c (build_original_schedule): Return nothing. * gcc.dg/graphite/scop-10.c: Enlarge array to avoid undefined behavior. * gcc.dg/graphite/scop-7.c: Likewise. * gcc.dg/graphite/scop-8.c: Likewise. From-SVN: r253719 --- gcc/ChangeLog | 13 +++++++++ gcc/graphite-isl-ast-to-gimple.c | 37 +++++++++++++------------ gcc/graphite-sese-to-poly.c | 5 +--- gcc/testsuite/ChangeLog | 7 +++++ gcc/testsuite/gcc.dg/graphite/scop-10.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-7.c | 2 +- gcc/testsuite/gcc.dg/graphite/scop-8.c | 2 +- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57686022742..8f764889fb4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2017-10-13 Richard Biener + + * graphite-isl-ast-to-gimple.c (max_mode_int_precision, + graphite_expression_type_precision): Avoid global constructor + by moving ... + (translate_isl_ast_to_gimple::translate_isl_ast_to_gimple): Here. + (translate_isl_ast_to_gimple::graphite_expr_type): Add type + member. + (translate_isl_ast_to_gimple::translate_isl_ast_node_for): Use it. + (translate_isl_ast_to_gimple::build_iv_mapping): Likewise. + (translate_isl_ast_to_gimple::graphite_create_new_guard): Likewise. + * graphite-sese-to-poly.c (build_original_schedule): Return nothing. + 2017-10-13 H.J. Lu PR target/82499 diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index 874941824cd..b761fadef20 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -58,15 +58,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa.h" #include "graphite.h" -/* We always try to use signed 128 bit types, but fall back to smaller types - in case a platform does not provide types of these sizes. In the future we - should use isl to derive the optimal type for each subexpression. */ - -static int max_mode_int_precision = - GET_MODE_PRECISION (int_mode_for_size (MAX_FIXED_MODE_SIZE, 0).require ()); -static int graphite_expression_type_precision = 128 <= max_mode_int_precision ? - 128 : max_mode_int_precision; - struct ast_build_info { ast_build_info() @@ -143,8 +134,7 @@ enum phi_node_kind class translate_isl_ast_to_gimple { public: - translate_isl_ast_to_gimple (sese_info_p r) - : region (r), codegen_error (false) { } + translate_isl_ast_to_gimple (sese_info_p r); edge translate_isl_ast (loop_p context_loop, __isl_keep isl_ast_node *node, edge next_e, ivs_params &ip); edge translate_isl_ast_node_for (loop_p context_loop, @@ -235,8 +225,24 @@ private: /* A vector of all the edges at if_condition merge points. */ auto_vec merge_points; + + tree graphite_expr_type; }; +translate_isl_ast_to_gimple::translate_isl_ast_to_gimple (sese_info_p r) + : region (r), codegen_error (false) +{ + /* We always try to use signed 128 bit types, but fall back to smaller types + in case a platform does not provide types of these sizes. In the future we + should use isl to derive the optimal type for each subexpression. */ + int max_mode_int_precision + = GET_MODE_PRECISION (int_mode_for_size (MAX_FIXED_MODE_SIZE, 0).require ()); + int graphite_expr_type_precision + = 128 <= max_mode_int_precision ? 128 : max_mode_int_precision; + graphite_expr_type + = build_nonstandard_integer_type (graphite_expr_type_precision, 0); +} + /* Return the tree variable that corresponds to the given isl ast identifier expression (an isl_ast_expr of type isl_ast_expr_id). @@ -702,8 +708,7 @@ translate_isl_ast_node_for (loop_p context_loop, __isl_keep isl_ast_node *node, edge next_e, ivs_params &ip) { gcc_assert (isl_ast_node_get_type (node) == isl_ast_node_for); - tree type - = build_nonstandard_integer_type (graphite_expression_type_precision, 0); + tree type = graphite_expr_type; isl_ast_expr *for_init = isl_ast_node_for_get_init (node); tree lb = gcc_expression_from_isl_expression (type, for_init, ip); @@ -742,8 +747,7 @@ build_iv_mapping (vec iv_map, gimple_poly_bb_p gbb, for (i = 1; i < isl_ast_expr_get_op_n_arg (user_expr); i++) { arg_expr = isl_ast_expr_get_op_arg (user_expr, i); - tree type = - build_nonstandard_integer_type (graphite_expression_type_precision, 0); + tree type = graphite_expr_type; tree t = gcc_expression_from_isl_expression (type, arg_expr, ip); /* To fail code generation, we generate wrong code until we discard it. */ @@ -841,8 +845,7 @@ edge translate_isl_ast_to_gimple:: graphite_create_new_guard (edge entry_edge, __isl_take isl_ast_expr *if_cond, ivs_params &ip) { - tree type = - build_nonstandard_integer_type (graphite_expression_type_precision, 0); + tree type = graphite_expr_type; tree cond_expr = gcc_expression_from_isl_expression (type, if_cond, ip); /* To fail code generation, we generate wrong code until we discard it. */ diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index ed6cbeccca1..fc16ca969eb 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -1194,7 +1194,7 @@ build_schedule_loop_nest (scop_p scop, int *index, loop_p context_loop) /* Build the schedule of the SCOP. */ -static bool +static void build_original_schedule (scop_p scop) { int i = 0; @@ -1216,9 +1216,6 @@ build_original_schedule (scop_p scop) fprintf (dump_file, "[sese-to-poly] original schedule:\n"); print_isl_schedule (dump_file, scop->original_schedule); } - if (!scop->original_schedule) - return false; - return true; } /* Builds the polyhedral representation for a SESE region. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 30ab9bd49e5..29dace44462 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-10-13 Richard Biener + + * gcc.dg/graphite/scop-10.c: Enlarge array to avoid undefined + behavior. + * gcc.dg/graphite/scop-7.c: Likewise. + * gcc.dg/graphite/scop-8.c: Likewise. + 2017-10-13 H.J. Lu PR target/82499 diff --git a/gcc/testsuite/gcc.dg/graphite/scop-10.c b/gcc/testsuite/gcc.dg/graphite/scop-10.c index 39ed5d7ea7b..20d53510b4e 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-10.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-10.c @@ -4,7 +4,7 @@ int toto() { int i, j, k; int a[100][100]; - int b[100]; + int b[200]; for (i = 1; i < 100; i++) { diff --git a/gcc/testsuite/gcc.dg/graphite/scop-7.c b/gcc/testsuite/gcc.dg/graphite/scop-7.c index 3e337d0c603..2f0a50470e9 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-7.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-7.c @@ -4,7 +4,7 @@ int toto() { int i, j, k; int a[100][100]; - int b[100]; + int b[200]; for (i = 1; i < 100; i++) { diff --git a/gcc/testsuite/gcc.dg/graphite/scop-8.c b/gcc/testsuite/gcc.dg/graphite/scop-8.c index 71d5c531fb8..3ceb5d874d6 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-8.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-8.c @@ -4,7 +4,7 @@ int toto() { int i, j, k; int a[100][100]; - int b[100]; + int b[200]; for (i = 1; i < 100; i++) { -- 2.30.2