From patchwork Fri Aug 5 10:08:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 56554 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 ED0263857BA6 for ; Fri, 5 Aug 2022 10:08:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED0263857BA6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659694129; bh=2wwlytsHIXSEUiS6GijcQ1PznN6grm4F437EbohCieA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yCISLoPRn2HcQ1k7YNELjgs8RN6S0dD8btKBZTKVhMVzH5MawV/8fGtCb27fSYAOT 7MLP2Fgu1qRLZBrwAoXo2erIVDUi/ti6jh5jHYaC31S3VK7Fc2VSPulvuemiaUX5ye PHCbP/1GdqPLKMKbMtTvGeXc6W3lpwzCjLqYRBe8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id A0BB9385B83D for ; Fri, 5 Aug 2022 10:08:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A0BB9385B83D Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 60B60381F1 for ; Fri, 5 Aug 2022 10:08:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4CEDA13A9C for ; Fri, 5 Aug 2022 10:08:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id w8aVERHs7GLHYwAAMHmgww (envelope-from ) for ; Fri, 05 Aug 2022 10:08:17 +0000 Date: Fri, 5 Aug 2022 12:08:16 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106533 - loop distribution of inner loop of nest MIME-Version: 1.0 Message-Id: <20220805100817.4CEDA13A9C@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Loop distribution currently gives up if the outer loop of a loop nest it analyzes contains a stmt with side-effects instead of continuing to analyze the innermost loop. The following fixes that by continuing anyway. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106533 * tree-loop-distribution.cc (loop_distribution::execute): Continue analyzing the inner loops when find_seed_stmts_for_distribution fails. * gcc.dg/tree-ssa/ldist-39.c: New testcase. --- gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c | 16 ++++++++++++++++ gcc/tree-loop-distribution.cc | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c new file mode 100644 index 00000000000..3ef72864d96 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c @@ -0,0 +1,16 @@ +/* PR/106533 */ +/* { dg-options "-O2 -fdump-tree-ldist-optimized" } */ + +void bar (int *a, int * __restrict b) +{ + for (int k = 0; k < 10; k++) + { + for (int j = 0; j < 100000; ++j) + a[j] = b[j]; + __builtin_printf ("Foo!"); + } +} + +/* The stmt with side-effects in the outer loop should not prevent + distribution of the inner loop of the loop nest. */ +/* { dg-final { scan-tree-dump "optimized: Loop . distributed: split to 0 loops and 1 library calls" "ldist" } } */ diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index 0ee441c077d..e1948fb452a 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -3829,7 +3829,7 @@ loop_distribution::execute (function *fun) { auto_vec work_list; if (!find_seed_stmts_for_distribution (loop, &work_list)) - break; + continue; const char *str = loop->inner ? " nest" : ""; dump_user_location_t loc = find_loop_location (loop);