]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
graphite: Adjust scop loop-nest choice
authorFrederik Harwath <frederik@codesourcery.com>
Tue, 16 Nov 2021 15:21:57 +0000 (16:21 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:54 +0000 (14:11 +0100)
The find_common_loop function is used in Graphite to obtain a common
super-loop of all loops inside a SCoP.  The function is applied to the
loop of the destination block of the edge that leads into the SESE
region and the loop of the source block of the edge that exits the
region.  The exit block is usually introduced by the canonicalization
of the loop structure that Graphite does to support its code
generation. If it is empty, it may happen that it belongs to the outer
fake loop.  This way, build_alias_set may end up analysing
data-references with respect to this loop although there may exist a
proper super-loop of the SCoP loops.  This does not seem to be correct
in general and it leads to problems with runtime alias check creation
which fails if executed on a loop without niter information.

gcc/ChangeLog:

        * graphite-scop-detection.cc (scop_context_loop): New function.
        (build_alias_set): Use scop_context_loop instead of find_common_loop.
        * graphite-isl-ast-to-gimple.cc (graphite_regenerate_ast_isl): Likewise.
        * graphite.h (scop_context_loop): New declaration.

gcc/ChangeLog.omp
gcc/graphite-isl-ast-to-gimple.cc
gcc/graphite-scop-detection.cc
gcc/graphite.h

index 955e3a2222f76fa98d60626dcc9ec1f114beaa9e..8773233b4d9844ed8db20d298de443ec669d12a7 100644 (file)
@@ -1,3 +1,10 @@
+2021-11-16  Frederik Harwath  <frederik@codesourcery.com>
+
+       * graphite-scop-detection.cc (scop_context_loop): New function.
+       (build_alias_set): Use scop_context_loop instead of find_common_loop.
+       * graphite-isl-ast-to-gimple.cc (graphite_regenerate_ast_isl): Likewise.
+       * graphite.h (scop_context_loop): New declaration.
+
 2021-11-16  Frederik Harwath  <frederik@codesourcery.com>
 
        * graphite-optimize-isl.cc (optimize_isl): Adjust
index 9350f5ead41a7a3247085817c7ccfb8f5dcadc2a..49cbb9d5cfe404d82f14430f01c88c1dcebb9fba 100644 (file)
@@ -1539,9 +1539,7 @@ graphite_regenerate_ast_isl (scop_p scop)
         conditional if aliasing can be ruled out at runtime and the original
         version of the SCoP, otherwise. */
 
-      loop_p loop
-         = find_common_loop (scop->scop_info->region.entry->dest->loop_father,
-                             scop->scop_info->region.exit->src->loop_father);
+      loop_p loop = scop_context_loop (scop);
       tree cond = generate_alias_cond (scop->unhandled_alias_ddrs, loop);
       tree non_alias_cond = build1 (TRUTH_NOT_EXPR, boolean_type_node, cond);
       set_ifsese_condition (region->if_region, non_alias_cond);
index 8656e4b1e99f1a2dd4fd40e1858a0ee19244602c..f4dba010bde7820a9688b1f53cb5cdb564d4fa97 100644 (file)
@@ -297,6 +297,23 @@ single_pred_cond_non_loop_exit (basic_block bb)
   return NULL;
 }
 
+
+/* Return the innermost loop that encloses all loops in SCOP. */
+
+loop_p
+scop_context_loop (scop_p scop)
+{
+  edge scop_entry = scop->scop_info->region.entry;
+  edge scop_exit = scop->scop_info->region.exit;
+  basic_block exit_bb = scop_exit->src;
+
+  while (sese_trivially_empty_bb_p (exit_bb) && single_pred_p (exit_bb))
+    exit_bb = single_pred (exit_bb);
+
+  loop_p entry_loop = scop_entry->dest->loop_father;
+  return find_common_loop (entry_loop, exit_bb->loop_father);
+}
+
 namespace
 {
 
@@ -1774,9 +1791,7 @@ build_alias_set (scop_p scop)
   int i, j;
   int *all_vertices;
 
-  struct loop *nest
-    = find_common_loop (scop->scop_info->region.entry->dest->loop_father,
-                       scop->scop_info->region.exit->src->loop_father);
+  struct loop *nest = scop_context_loop (scop);
 
   gcc_checking_assert (nest);
 
index 69d5579c78af5b86595d857da53dfe66abe32c67..42599e8089355555d1e76e35d148166d1525e30b 100644 (file)
@@ -480,4 +480,5 @@ extern tree cached_scalar_evolution_in_region (const sese_l &, loop_p, tree);
 extern void dot_all_sese (FILE *, vec<sese_l> &);
 extern void dot_sese (sese_l &);
 extern void dot_cfg ();
+extern loop_p scop_context_loop (scop_p);
 #endif