2017-10-13 Richard Biener <rguenther@suse.de>
authorRichard Biener <rguenther@suse.de>
Fri, 13 Oct 2017 11:02:05 +0000 (11:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 13 Oct 2017 11:02:05 +0000 (11:02 +0000)
* graphite-isl-ast-to-gimple.c
(translate_isl_ast_to_gimple::get_rename_from_scev): Remove unused
parameters and dominance check.
(translate_isl_ast_to_gimple::graphite_copy_stmts_from_block): Adjust.
(translate_isl_ast_to_gimple::copy_bb_and_scalar_dependences): Likewise.
(translate_isl_ast_to_gimple::graphite_regenerate_ast_isl):
Do not update SSA form here or do intermediate IL verification.
* graphite.c: Include tree-ssa.h and tree-into-ssa.h.
(graphite_initialize): Remove check on the number of loops in
the function and inline into graphite_transform_loops.
(graphite_finalize): Inline into graphite_transform_loops.
(graphite_transform_loops): Perform SSA update and IL verification
here.
* params.def (PARAM_GRAPHITE_MIN_LOOPS_PER_FUNCTION): Remove.

* gcc.dg/graphite/pr35356-3.c: XFAIL again.
* gcc.dg/graphite/pr81373-2.c: Copy from gcc.dg/graphite/pr81373.c
with alternate flags.

From-SVN: r253720

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c
gcc/graphite.c
gcc/params.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr35356-3.c

index 8f764889fb4700fbd2a27cab11837db9008058b4..649e2e8a3032dc2771362fe02b3656c244e99482 100644 (file)
@@ -1,3 +1,20 @@
+2017-10-13  Richard Biener  <rguenther@suse.de>
+
+       * graphite-isl-ast-to-gimple.c
+       (translate_isl_ast_to_gimple::get_rename_from_scev): Remove unused
+       parameters and dominance check.
+       (translate_isl_ast_to_gimple::graphite_copy_stmts_from_block): Adjust.
+       (translate_isl_ast_to_gimple::copy_bb_and_scalar_dependences): Likewise.
+       (translate_isl_ast_to_gimple::graphite_regenerate_ast_isl):
+       Do not update SSA form here or do intermediate IL verification.
+       * graphite.c: Include tree-ssa.h and tree-into-ssa.h.
+       (graphite_initialize): Remove check on the number of loops in
+       the function and inline into graphite_transform_loops.
+       (graphite_finalize): Inline into graphite_transform_loops.
+       (graphite_transform_loops): Perform SSA update and IL verification
+       here.
+       * params.def (PARAM_GRAPHITE_MIN_LOOPS_PER_FUNCTION): Remove.
+
 2017-10-13  Richard Biener  <rguenther@suse.de>
 
        * graphite-isl-ast-to-gimple.c (max_mode_int_precision,
index b761fadef205bc18da2b58eaf9eb3ab04d6702b7..2a583aba63bd5ebdb25fec324325dd92fc8d7ee3 100644 (file)
@@ -189,7 +189,6 @@ class translate_isl_ast_to_gimple
   __isl_give isl_ast_node * scop_to_isl_ast (scop_p scop);
 
   tree get_rename_from_scev (tree old_name, gimple_seq *stmts, loop_p loop,
-                            basic_block new_bb, basic_block old_bb,
                             vec<tree> iv_map);
   bool graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
                                       vec<tree> iv_map);
@@ -1084,7 +1083,6 @@ gsi_insert_earliest (gimple_seq seq)
 
 tree translate_isl_ast_to_gimple::
 get_rename_from_scev (tree old_name, gimple_seq *stmts, loop_p loop,
-                     basic_block new_bb, basic_block,
                      vec<tree> iv_map)
 {
   tree scev = scalar_evolution_in_region (region->region, loop, old_name);
@@ -1113,16 +1111,6 @@ get_rename_from_scev (tree old_name, gimple_seq *stmts, loop_p loop,
       return build_zero_cst (TREE_TYPE (old_name));
     }
 
-  if (TREE_CODE (new_expr) == SSA_NAME)
-    {
-      basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (new_expr));
-      if (bb && !dominated_by_p (CDI_DOMINATORS, new_bb, bb))
-       {
-         set_codegen_error ();
-         return build_zero_cst (TREE_TYPE (old_name));
-       }
-    }
-
   /* Replace the old_name with the new_expr.  */
   return force_gimple_operand (unshare_expr (new_expr), stmts,
                               true, NULL_TREE);
@@ -1245,8 +1233,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
              {
                gimple_seq stmts = NULL;
                new_name = get_rename_from_scev (old_name, &stmts,
-                                                bb->loop_father,
-                                                new_bb, bb, iv_map);
+                                                bb->loop_father, iv_map);
                if (! codegen_error_p ())
                  gsi_insert_earliest (stmts);
                new_expr = &new_name;
@@ -1361,7 +1348,7 @@ copy_bb_and_scalar_dependences (basic_block bb, edge next_e, vec<tree> iv_map)
                  gimple_seq stmts = NULL;
                  tree new_name = get_rename_from_scev (arg, &stmts,
                                                        bb->loop_father,
-                                                       new_bb, bb, iv_map);
+                                                       iv_map);
                  if (! codegen_error_p ())
                    gsi_insert_earliest (stmts);
                  arg = new_name;
@@ -1567,17 +1554,6 @@ graphite_regenerate_ast_isl (scop_p scop)
                                     if_region->true_region->region.exit);
       if (dump_file)
        fprintf (dump_file, "[codegen] isl AST to Gimple succeeded.\n");
-
-      mark_virtual_operands_for_renaming (cfun);
-      update_ssa (TODO_update_ssa);
-      checking_verify_ssa (true, true);
-      rewrite_into_loop_closed_ssa (NULL, 0);
-      /* We analyzed evolutions of all SCOPs during SCOP detection
-         which cached evolutions.  Now we've introduced PHIs for
-        liveouts which causes those cached solutions to be invalid
-        for code-generation purposes given we'd insert references
-        to SSA names not dominating their new use.  */
-      scev_reset ();
     }
 
   if (t.codegen_error_p ())
@@ -1587,9 +1563,6 @@ graphite_regenerate_ast_isl (scop_p scop)
                 "reverting back to the original code.\n");
       set_ifsese_condition (if_region, integer_zero_node);
 
-      /* We registered new names, scrap that.  */
-      if (need_ssa_update_p (cfun))
-       delete_update_ssa ();
       /* Remove the unreachable region.  */
       remove_edge_and_dominated_blocks (if_region->true_region->region.entry);
       basic_block ifb = if_region->false_region->region.entry->src;
@@ -1605,9 +1578,11 @@ graphite_regenerate_ast_isl (scop_p scop)
          delete_loop (loop);
     }
 
-  /* Verifies properties that GRAPHITE should maintain during translation.  */
-  checking_verify_loop_structure ();
-  checking_verify_loop_closed_ssa (true);
+  /* We are delaying SSA update to after code-generating all SCOPs.
+     This is because we analyzed DRs and parameters on the unmodified
+     IL and thus rely on SSA update to pick up new dominating definitions
+     from for example SESE liveout PHIs.  This is also for efficiency
+     as SSA update does work depending on the size of the function.  */
 
   free (if_region->true_region);
   free (if_region->region);
index 0bdcc28cba8a3f0f775bbbae88aaa0c0365fbabb..d11de71a9b87d4b9382819ccf02576fce531b8f5 100644 (file)
@@ -55,6 +55,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-cfgcleanup.h"
 #include "tree-vectorizer.h"
 #include "tree-ssa-loop-manip.h"
+#include "tree-ssa.h"
+#include "tree-into-ssa.h"
 #include "graphite.h"
 
 /* Print global statistics to FILE.  */
@@ -212,64 +214,6 @@ print_graphite_statistics (FILE* file, vec<scop_p> scops)
   print_loops (file, 3);
 }
 
-/* Initialize graphite: when there are no loops returns false.  */
-
-static bool
-graphite_initialize (void)
-{
-  int min_loops = PARAM_VALUE (PARAM_GRAPHITE_MIN_LOOPS_PER_FUNCTION);
-  int nloops = number_of_loops (cfun);
-
-  if (nloops <= min_loops)
-    {
-      if (dump_file && (dump_flags & TDF_DETAILS))
-       {
-         if (nloops <= min_loops)
-           fprintf (dump_file, "\nFunction does not have enough loops: "
-                    "PARAM_GRAPHITE_MIN_LOOPS_PER_FUNCTION = %d.\n",
-                    min_loops);
-
-         fprintf (dump_file, "\nnumber of SCoPs: 0\n");
-         print_global_statistics (dump_file);
-       }
-
-      return false;
-    }
-
-  calculate_dominance_info (CDI_DOMINATORS);
-  initialize_original_copy_tables ();
-
-  if (dump_file && dump_flags)
-    {
-      dump_function_to_file (current_function_decl, dump_file, dump_flags);
-      print_loops (dump_file, 3);
-    }
-
-  return true;
-}
-
-/* Finalize graphite: perform CFG cleanup when NEED_CFG_CLEANUP_P is
-   true.  */
-
-static void
-graphite_finalize (bool need_cfg_cleanup_p)
-{
-  if (need_cfg_cleanup_p)
-    {
-      free_dominance_info (CDI_DOMINATORS);
-      scev_reset ();
-      cleanup_tree_cfg ();
-      profile_status_for_fn (cfun) = PROFILE_ABSENT;
-      release_recorded_exits (cfun);
-      tree_estimate_probability (false);
-    }
-
-  free_original_copy_tables ();
-
-  if (dump_file && dump_flags)
-    print_loops (dump_file, 3);
-}
-
 /* Deletes all scops in SCOPS.  */
 
 static void
@@ -396,7 +340,7 @@ graphite_transform_loops (void)
 {
   int i;
   scop_p scop;
-  bool need_cfg_cleanup_p = false;
+  bool changed = false;
   vec<scop_p> scops = vNULL;
   isl_ctx *ctx;
 
@@ -405,8 +349,7 @@ graphite_transform_loops (void)
   if (parallelized_function_p (cfun->decl))
     return;
 
-  if (!graphite_initialize ())
-    return;
+  calculate_dominance_info (CDI_DOMINATORS);
 
   ctx = isl_ctx_alloc ();
   isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT);
@@ -438,7 +381,7 @@ graphite_transform_loops (void)
        location_t loc = find_loop_location
          (scops[i]->scop_info->region.entry->dest->loop_father);
 
-       need_cfg_cleanup_p = true;
+       changed = true;
        if (!graphite_regenerate_ast_isl (scop))
          dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
                           "loop nest not optimized, code generation error\n");
@@ -447,6 +390,16 @@ graphite_transform_loops (void)
                           "loop nest optimized\n");
       }
 
+  if (changed)
+    {
+      mark_virtual_operands_for_renaming (cfun);
+      update_ssa (TODO_update_ssa);
+      checking_verify_ssa (true, true);
+      rewrite_into_loop_closed_ssa (NULL, 0);
+      scev_reset ();
+      checking_verify_loop_structure ();
+    }
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       loop_p loop;
@@ -461,9 +414,17 @@ graphite_transform_loops (void)
     }
 
   free_scops (scops);
-  graphite_finalize (need_cfg_cleanup_p);
   the_isl_ctx = NULL;
   isl_ctx_free (ctx);
+
+  if (changed)
+    {
+      cleanup_tree_cfg ();
+      profile_status_for_fn (cfun) = PROFILE_ABSENT;
+      release_recorded_exits (cfun);
+      tree_estimate_probability (false);
+    }
+
 }
 
 #else /* If isl is not available: #ifndef HAVE_isl.  */
index e55afc28053039b258d83fa369c38b5b9977fec6..8881f4c403a0731b065283274f67435575bc8d59 100644 (file)
@@ -882,13 +882,6 @@ DEFPARAM (PARAM_GRAPHITE_MAX_ARRAYS_PER_SCOP,
          "maximum number of arrays per scop.",
          100, 0, 0)
 
-/* Maximal number of basic blocks in the functions analyzed by Graphite.  */
-
-DEFPARAM (PARAM_GRAPHITE_MIN_LOOPS_PER_FUNCTION,
-         "graphite-min-loops-per-function",
-         "minimal number of loops per function to be analyzed by Graphite.",
-         2, 0, 0)
-
 DEFPARAM (PARAM_MAX_ISL_OPERATIONS,
          "max-isl-operations",
          "maximum number of isl operations, 0 means unlimited",
index 29dace4446286e8fb177b96df5ea1f1d53cd3f9d..90a7f722111aa4e0028846bfc2138d1b078eb49a 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-13  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/graphite/pr35356-3.c: XFAIL again.
+       * gcc.dg/graphite/pr81373-2.c: Copy from gcc.dg/graphite/pr81373.c
+       with alternate flags.
+
 2017-10-13  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/graphite/scop-10.c: Enlarge array to avoid undefined
index f2827a2bb6d63498bbb486e0c39ce9047699f0cd..8db042ffc6f6ee2c0b4c8bf0055c08bbaaa24561 100644 (file)
@@ -36,4 +36,5 @@ match (void)
    "Y[winner].y > 0".  This could be fixed when we will use predicates
    for such cases.  */
 
-/* { dg-final { scan-tree-dump-times "loop_1" 0 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "loop_1" 0 "graphite" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "number of SCoPs: 0" "graphite" } } */