From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id E03133847813 for ; Wed, 23 Jun 2021 13:16:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E03133847813 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id F19A41FD65; Wed, 23 Jun 2021 13:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1624454175; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=h+TF5+AeO0BuF3H/2IVALvnxOzKGHROBj1em8keOxeM=; b=biuC6fSoIVtsbmaLVggvS2z5+/BztoR+UqNPoA7vEcBpfK85zIGvuj74FgSRbTD08fGKdP G0Vxzf3EgQ5BZvAKJjGOQqsivWMZJ7tGTz368tkjpPafQNFg9dqya+m6UZLKlHC5SVcHDI JopGzGY2KCwDvp51GIKpkoIbjKqbdAg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1624454175; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=h+TF5+AeO0BuF3H/2IVALvnxOzKGHROBj1em8keOxeM=; b=zDXdcheyxVL+7UXO5Pe3l8mlBPb/WW39AvmWnVAMk41VvZwF8MyKwyOWcOJr55qcvFNPBm Pfkxkhg0pqTpnVCg== Received: from [10.163.28.26] (unknown [10.163.28.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D2E78A3BA3; Wed, 23 Jun 2021 13:16:15 +0000 (UTC) Date: Wed, 23 Jun 2021 15:16:15 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: bin.cheng@linux.alibaba.com Subject: [PATCH] tree-optimization/101173 - fix interchange dependence checking Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.7 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 23 Jun 2021 13:16:21 -0000 This adjusts the loop interchange dependence checking to disallow an outer loop dependence distance of zero. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. 2021-06-23 Richard Biener PR tree-optimization/101173 * gimple-loop-interchange.cc (tree_loop_interchange::valid_data_dependences): Disallow outer loop dependence distance of zero. * gcc.dg/torture/pr101173.c: New testcase. --- gcc/gimple-loop-interchange.cc | 4 ++-- gcc/testsuite/gcc.dg/torture/pr101173.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr101173.c diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc index 80f749b6071..43045c5455e 100644 --- a/gcc/gimple-loop-interchange.cc +++ b/gcc/gimple-loop-interchange.cc @@ -1043,8 +1043,8 @@ tree_loop_interchange::valid_data_dependences (unsigned i_idx, unsigned o_idx, continue; /* Be conservative, skip case if either direction at i_idx/o_idx - levels is not '=' or '<'. */ - if (dist_vect[i_idx] < 0 || dist_vect[o_idx] < 0) + levels is not '=' (for the inner loop) or '<'. */ + if (dist_vect[i_idx] < 0 || dist_vect[o_idx] <= 0) return false; } } diff --git a/gcc/testsuite/gcc.dg/torture/pr101173.c b/gcc/testsuite/gcc.dg/torture/pr101173.c new file mode 100644 index 00000000000..0c9090d6686 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101173.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-additional-options "-floop-interchange" } */ + +int a[6][9]; +int main() +{ + a[1][3] = 8; + for (int b = 1; b <= 5; b++) + for (int d = 0; d <= 5; d++) +#pragma GCC unroll 0 + for (int c = 0; c <= 5; c++) + a[b][c] = a[b][c + 2] & 216; + for (int e = 0; e < 6; e++) + for (int f = 0; f < 9; f++) + if (a[e][f] != 0) + __builtin_abort (); + return 0; +} -- 2.26.2