From patchwork Fri Jun 11 09:26:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1490840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=lgjBW5zb; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=6kll5EY9; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G1b7r2hWrz9sX5 for ; Fri, 11 Jun 2021 19:26:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 651453AAA07D for ; Fri, 11 Jun 2021 09:26:27 +0000 (GMT) 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 12A643844012 for ; Fri, 11 Jun 2021 09:26:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 12A643844012 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-out1.suse.de (Postfix) with ESMTP id BF6E4219A1 for ; Fri, 11 Jun 2021 09:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623403561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=wyw3JrBhK77f8DucPhewnDW3fdanv5IdzZN54tud3ss=; b=lgjBW5zb1cacSEO30A4Cu4kbXvIHMq+MBocNF5ieO65ZxwDulIHnV+mRJLKWZV2qMaJ6qh 97DltmHoK3DtfcAIdaGbJihivcAifJFiNf7UiaW6AR4gmfXdn1HfGMuoDJnEm+1J/TcILi DTi5/mflmbxm6L56HxN4usiKwXeNyng= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623403561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=wyw3JrBhK77f8DucPhewnDW3fdanv5IdzZN54tud3ss=; b=6kll5EY9+miQsp3UaLU3JOFkN+f+OJQRVdjWl+FJjri0bj0XJeNvahSTXRBYTwxvErlUtA CTl5LbJ//Rjc2NAg== 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 AEF29A3BE8 for ; Fri, 11 Jun 2021 09:26:01 +0000 (UTC) Date: Fri, 11 Jun 2021 11:26:01 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] middle-end/101009 - fix distance vector recording Message-ID: <14pn234n-819q-818n-51ps-53pqs94ps06q@fhfr.qr> MIME-Version: 1.0 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This fixes recording of distance vectors in case the DDR has just constant equal indexes. In that case we expect distance vectors with zero distances to be recorded which is what was done when any distance was computed for affine indexes. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-06-11 Richard Biener PR middle-end/101009 * tree-data-ref.c (build_classic_dist_vector_1): Make sure to set *init_b to true when we encounter a constant equal index pair. (compute_affine_dependence): Also dump the actual DR_REF. * gcc.dg/torture/pr101009.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr101009.c | 17 +++++++++++++++++ gcc/tree-data-ref.c | 10 ++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr101009.c diff --git a/gcc/testsuite/gcc.dg/torture/pr101009.c b/gcc/testsuite/gcc.dg/torture/pr101009.c new file mode 100644 index 00000000000..2bbed1dfc2c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101009.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fno-tree-sra -fno-tree-pre -ftree-loop-distribution" } */ + +struct a { + unsigned b; + unsigned c; +} e, *f = &e; +int d = 1; +int main() { + for (; d; d--) { + struct a g[] = {{2, 1}, {2, 1}}; + *f = g[1]; + } + if (e.c != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b1f64684840..b37c234aea8 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -5121,6 +5121,8 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr, non_affine_dependence_relation (ddr); return false; } + else + *init_b = true; } return true; @@ -5616,9 +5618,13 @@ compute_affine_dependence (struct data_dependence_relation *ddr, if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "(compute_affine_dependence\n"); - fprintf (dump_file, " stmt_a: "); + fprintf (dump_file, " ref_a: "); + print_generic_expr (dump_file, DR_REF (dra)); + fprintf (dump_file, ", stmt_a: "); print_gimple_stmt (dump_file, DR_STMT (dra), 0, TDF_SLIM); - fprintf (dump_file, " stmt_b: "); + fprintf (dump_file, " ref_b: "); + print_generic_expr (dump_file, DR_REF (drb)); + fprintf (dump_file, ", stmt_b: "); print_gimple_stmt (dump_file, DR_STMT (drb), 0, TDF_SLIM); }