From patchwork Mon Feb 17 13:17:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1239219 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519640-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=I+z3Pfk0; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Ll0D73Kgz9sRJ for ; Tue, 18 Feb 2020 00:17:47 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=oaqlnfK5Ecx5h06HJjMfYtEJ9ePNQ9AgBCeubpZbhhcdTv0HWt AYPUuNS4eBlQfOmEAqPyKQYzA1woU049hx6QQCLBmm4QUhJOa0/TP7Uv/2vjQLZ6 sf/8E4gy7FayUDMQjLjGCssHRKBPSbthoQmvAnFYaM9a9SRMkh106+7uM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=2JX52j/0HxBY+hyIUgYYcCR3BXs=; b=I+z3Pfk0iJVIdnq6TyC7 dudE1jqr9zENT9vul30QKoHRcV8AxFp3Kfgjn3tTBat5CkCxAnaxHRV/QpRaX4Re YB3tb/qc+UoZfp7KdX/WeBDDhw7B1uO3ZhA8+muxVZPvA8ylsjAm1Dy1CAig1gYp htB0kJ7YzHAL6CnZHZuYB3Y= Received: (qmail 12835 invoked by alias); 17 Feb 2020 13:17:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12824 invoked by uid 89); 17 Feb 2020 13:17:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Feb 2020 13:17:37 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D6C26AE19; Mon, 17 Feb 2020 13:17:35 +0000 (UTC) Date: Mon, 17 Feb 2020 14:17:35 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] tree-optimization/93586 - bogus path-based disambiguation Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 This fixes bogus path-based disambiguation of mismatched array shape accesses. Bootstrap & regtest running on x86_64-unknown-linux-gnu. Honza, is this the correct place to detect this or were we not supposed to arrive there? Thanks, Richard. 2020-02-17 Richard Biener PR tree-optimization/93586 * tree-ssa-alias.c (nonoverlapping_array_refs_p): Fail when we're obviously not looking at same-shaped array accesses. * gcc.dg/torture/pr93586.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr93586.c | 21 +++++++++++++++++++++ gcc/tree-ssa-alias.c | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr93586.c diff --git a/gcc/testsuite/gcc.dg/torture/pr93586.c b/gcc/testsuite/gcc.dg/torture/pr93586.c new file mode 100644 index 00000000000..e861bdcd78e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr93586.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE(ssa) foo(int j) +{ + int c[1][10][1]; + int _1; + +__BB(2): + c[0][1][0] = 1; + c[0][1] = _Literal (int[1]) {}; + _1 = c[0][j_2(D)][0]; + return _1; +} + +int main() +{ + if (foo (1) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index b8df66ac1f2..e7caf9bee77 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1291,6 +1291,11 @@ nonoverlapping_array_refs_p (tree ref1, tree ref2) tree elmt_type1 = TREE_TYPE (TREE_TYPE (TREE_OPERAND (ref1, 0))); tree elmt_type2 = TREE_TYPE (TREE_TYPE (TREE_OPERAND (ref2, 0))); + /* If one element is an array but not the other there's an obvious + mismatch in dimensionality. */ + if ((TREE_CODE (elmt_type1) == ARRAY_TYPE) + != (TREE_CODE (elmt_type2) == ARRAY_TYPE)) + return -1; if (TREE_OPERAND (ref1, 3)) {