re PR tree-optimization/82591 ([graphite] Compile-time hog w/ -O2 -floop-nest-optimize)
authorRichard Biener <rguenther@suse.de>
Wed, 18 Oct 2017 14:35:26 +0000 (14:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 18 Oct 2017 14:35:26 +0000 (14:35 +0000)
2017-10-18  Richard Biener  <rguenther@suse.de>

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
gcc/graphite-isl-ast-to-gimple.c
gcc/graphite.c

index dcfa96f553ac633682d7dc7fa1725a7ad3fa069a..51ad45e7964e7eb5776cac8fa951ee322659d1a2 100644 (file)
@@ -1,3 +1,12 @@
+2017-10-18  Richard Biener  <rguenther@suse.de>
+
+       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  <rguenther@suse.de>
 
        * graphite-isl-ast-to-gimple.c
index dc5d56130bf42ebfe75f49da3a2d3e6468435410..e929193219ddce2b80fbf36cc89350722edf425a 100644 (file)
@@ -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);
index d11de71a9b87d4b9382819ccf02576fce531b8f5..5e0d66d107bb122bda33fb61b0639f752d767aa0 100644 (file)
@@ -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)