From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1729) id 299FB384D19A; Wed, 29 Jun 2022 14:42:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 299FB384D19A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Kwok Yeung To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] graphite: Adjust scop loop-nest choice X-Act-Checkin: gcc X-Git-Author: Frederik Harwath X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: cda804467466dc8e55f3e2d8e0a7f1c1ab700c52 X-Git-Newrev: b1e894b815ebf8d8a757cf324c93f17582b62b86 Message-Id: <20220629144253.299FB384D19A@sourceware.org> Date: Wed, 29 Jun 2022 14:42:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 14:42:53 -0000 https://gcc.gnu.org/g:b1e894b815ebf8d8a757cf324c93f17582b62b86 commit b1e894b815ebf8d8a757cf324c93f17582b62b86 Author: Frederik Harwath Date: Tue Nov 16 16:21:57 2021 +0100 graphite: Adjust scop loop-nest choice 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. Diff: --- gcc/ChangeLog.omp | 7 +++++++ gcc/graphite-isl-ast-to-gimple.cc | 4 +--- gcc/graphite-scop-detection.cc | 21 ++++++++++++++++++--- gcc/graphite.h | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 955e3a2222f..8773233b4d9 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-11-16 Frederik Harwath + + * 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 * graphite-optimize-isl.cc (optimize_isl): Adjust diff --git a/gcc/graphite-isl-ast-to-gimple.cc b/gcc/graphite-isl-ast-to-gimple.cc index 9350f5ead41..49cbb9d5cfe 100644 --- a/gcc/graphite-isl-ast-to-gimple.cc +++ b/gcc/graphite-isl-ast-to-gimple.cc @@ -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); diff --git a/gcc/graphite-scop-detection.cc b/gcc/graphite-scop-detection.cc index 8656e4b1e99..f4dba010bde 100644 --- a/gcc/graphite-scop-detection.cc +++ b/gcc/graphite-scop-detection.cc @@ -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); diff --git a/gcc/graphite.h b/gcc/graphite.h index 69d5579c78a..42599e80893 100644 --- a/gcc/graphite.h +++ b/gcc/graphite.h @@ -480,4 +480,5 @@ extern tree cached_scalar_evolution_in_region (const sese_l &, loop_p, tree); extern void dot_all_sese (FILE *, vec &); extern void dot_sese (sese_l &); extern void dot_cfg (); +extern loop_p scop_context_loop (scop_p); #endif