From patchwork Wed Dec 15 15:54:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederik Harwath X-Patchwork-Id: 48972 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 453DA3857C65 for ; Wed, 15 Dec 2021 16:15:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 6A8713858C3A for ; Wed, 15 Dec 2021 15:56:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A8713858C3A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: TmfV1brw0h+sFE1rwsNe6RXNR3BbuFg+UVhxEw8dop90HnXVWL0d7uiMKLCAsxJV+/zEfXzfpM KPGrPIJgKve9g7OUcIVlnuFFJu8hYmyZAnXYkUV8K7f17aOwE28JWolRLeQSh4/NWqX0cXnxSa iOpjkGk9q80/ahlIclnnMWvP4G0uhFFYL3p1/gcdU/2lwKE2ZFzYXh1bMwJjf3/XwmxRvvXmWz d7pL4KnG1ec+3ueF56WEtrvDdbV/Mq1Fs5fQcg7Z7OevoiRbWWFTiQE6iJDoMXZQEcYY1hjbLN 9UNWJGVoyUno71j0vtBGcLX9 X-IronPort-AV: E=Sophos;i="5.88,207,1635235200"; d="scan'208";a="69736624" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 15 Dec 2021 07:56:56 -0800 IronPort-SDR: XKi7jHDdVProZRuLe1xGMKr8iY3+vdakvTmEAfk6HAM5amRzOV5D7XxzdE47Mxn+23WWZntfPH I7j5/nYDtLB/Vc9h120DNhXtoMx9kymJnmogVgte3qrYXeOsVnNinkPihqm+iuWmu6aNAOwD69 nwKx7mFkbaJMmYtKe4BKwQuqWAhT0qMc3yB2lcSLw4/rcfPQMPX1NcEJNWDYCsBO2LYaIGESqg rdOjwRF+Cven+aPAOKCNizyEvfgekqwKYUAvY5v6TLu/M1x4BnE0DGkI/6fRg6PtMzp2kt5X+a h00= From: Frederik Harwath To: Subject: [PATCH 30/40] graphite: Adjust scop loop-nest choice Date: Wed, 15 Dec 2021 16:54:37 +0100 Message-ID: <20211215155447.19379-31-frederik@codesourcery.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211215155447.19379-1-frederik@codesourcery.com> References: <20211215155447.19379-1-frederik@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rguenther@suse.de, sebpop@gmail.com, thomas@codesourcery.com, grosser@fim.uni-passau.de Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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.c (scop_context_loop): New function. (build_alias_set): Use scop_context_loop instead of find_common_loop. * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Likewise. * graphite.h (scop_context_loop): New declaration. --- gcc/graphite-isl-ast-to-gimple.c | 4 +--- gcc/graphite-scop-detection.c | 21 ++++++++++++++++++--- gcc/graphite.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) -- 2.33.0 ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index 010adaabb000..acadf544fadd 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -1543,9 +1543,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.c b/gcc/graphite-scop-detection.c index 9a5e43a5bfc6..f173e6c4f890 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -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 9c508f31109f..dacb27a9073c 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