From e33507e33c20c23d4b72687ce5129dcc4c75f0be Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 18 Oct 2017 14:35:26 +0000 Subject: [PATCH] re PR tree-optimization/82591 ([graphite] Compile-time hog w/ -O2 -floop-nest-optimize) 2017-10-18 Richard Biener PR tree-optimization/82591 * graphite.c (graphite_transform_loops): Move code gen message printing ... * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Here. Handle scop_to_isl_ast failing. (scop_to_isl_ast): Limit the number of ISL operations. From-SVN: r253856 --- gcc/ChangeLog | 9 +++++++ gcc/graphite-isl-ast-to-gimple.c | 43 +++++++++++++++++++++++++++++--- gcc/graphite.c | 16 ++++++------ 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dcfa96f553a..51ad45e7964 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-10-18 Richard Biener + + PR tree-optimization/82591 + * graphite.c (graphite_transform_loops): Move code gen message + printing ... + * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): + Here. Handle scop_to_isl_ast failing. + (scop_to_isl_ast): Limit the number of ISL operations. + 2017-10-18 Richard Biener * graphite-isl-ast-to-gimple.c diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index dc5d56130bf..e929193219d 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see #include "cfganal.h" #include "value-prof.h" #include "tree-ssa.h" +#include "tree-vectorizer.h" #include "graphite.h" struct ast_build_info @@ -1350,6 +1351,13 @@ ast_build_before_for (__isl_keep isl_ast_build *build, void *user) __isl_give isl_ast_node *translate_isl_ast_to_gimple:: scop_to_isl_ast (scop_p scop) { + int old_err = isl_options_get_on_error (scop->isl_context); + 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->isl_context, max_operations); + isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_CONTINUE); + gcc_assert (scop->transformed_schedule); /* Set the separate option to reduce control flow overhead. */ @@ -1368,6 +1376,27 @@ scop_to_isl_ast (scop_p scop) isl_ast_node *ast_isl = isl_ast_build_node_from_schedule (context_isl, schedule); isl_ast_build_free (context_isl); + + isl_options_set_on_error (scop->isl_context, old_err); + isl_ctx_reset_operations (scop->isl_context); + isl_ctx_set_max_operations (scop->isl_context, old_max_operations); + if (isl_ctx_last_error (scop->isl_context) != isl_error_none) + { + location_t loc = find_loop_location + (scop->scop_info->region.entry->dest->loop_father); + if (isl_ctx_last_error (scop->isl_context) == isl_error_quota) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "loop nest not optimized, AST generation timed out " + "after %d operations [--param max-isl-operations]\n", + max_operations); + else + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "loop nest not optimized, ISL AST generation " + "signalled an error\n"); + isl_ast_node_free (ast_isl); + return NULL; + } + return ast_isl; } @@ -1416,6 +1445,12 @@ graphite_regenerate_ast_isl (scop_p scop) timevar_push (TV_GRAPHITE_CODE_GEN); t.add_parameters_to_ivs_params (scop, ip); root_node = t.scop_to_isl_ast (scop); + if (! root_node) + { + ivs_params_clear (ip); + timevar_pop (TV_GRAPHITE_CODE_GEN); + return false; + } if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1456,10 +1491,10 @@ graphite_regenerate_ast_isl (scop_p scop) if (t.codegen_error_p ()) { - if (dump_file) - fprintf (dump_file, "codegen error: " - "reverting back to the original code.\n"); - set_ifsese_condition (if_region, integer_zero_node); + location_t loc = find_loop_location + (scop->scop_info->region.entry->dest->loop_father); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "loop nest not optimized, code generation error\n"); /* Remove the unreachable region. */ remove_edge_and_dominated_blocks (if_region->true_region->region.entry); diff --git a/gcc/graphite.c b/gcc/graphite.c index d11de71a9b8..5e0d66d107b 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -378,16 +378,14 @@ graphite_transform_loops (void) if (!apply_poly_transforms (scop)) continue; - location_t loc = find_loop_location - (scops[i]->scop_info->region.entry->dest->loop_father); - changed = true; - if (!graphite_regenerate_ast_isl (scop)) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, - "loop nest not optimized, code generation error\n"); - else - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, - "loop nest optimized\n"); + if (graphite_regenerate_ast_isl (scop)) + { + location_t loc = find_loop_location + (scops[i]->scop_info->region.entry->dest->loop_father); + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "loop nest optimized\n"); + } } if (changed) -- 2.30.2