From patchwork Mon Oct 2 17:19:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 820630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463345-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BKQRZUPX"; 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 3y5TRp25gXz9t4c for ; Tue, 3 Oct 2017 04:19:33 +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=wALk6isqVEczoGZTzlOYhOs8PJEwLjfrHkfm+A8rGUpAi3EM0u FVeomeeHdgXokuQzNameJFRG2CZr6ke289YG2ATe79dgVfdXLk5e7ZJnwr3n//VQ kZIgHzkT6DgRou2HjpX3nmPy0YkC9bAoLwWMgYZp6+MhtUh1lGYJOvLUw= 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=YaN4AZ+7aya7MKXT+VszixgnXa4=; b=BKQRZUPXOHt4DnFEzwrL 7eMeR2EZNyDO4KcQkG9jnLazSYhgnXMNUj/FRqZ+n3IdqklhtN7TrZe83rnFoS4P Yx5nzVjsy/QFn4awhwU6Cfa9EQ5XW8BlgWcDANfiySxH+O5s8DQl2TbEOREWvua8 mzSZn+uCm7Qp32oDU0pucPo= Received: (qmail 40158 invoked by alias); 2 Oct 2017 17:19:23 -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 40130 invoked by uid 89); 2 Oct 2017 17:19:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 17:19:21 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 56258ABB4 for ; Mon, 2 Oct 2017 17:19:19 +0000 (UTC) Date: Mon, 2 Oct 2017 19:19:19 +0200 From: Martin Jambor To: GCC Patches Cc: Richard Biener Subject: [PR 82363] Fix thinko in SRA subaccess propagation Message-ID: <20171002171918.epfrxqihdqi6wrfn@virgil.suse.cz> Mail-Followup-To: GCC Patches , Richard Biener MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) X-IsSubscribed: yes Hi, the following fixes a thinko in propagate_subaccesses_across_link. When we cannot copy over a tree of accesses of RHS to LHS because of some conflict, we must mark the whole LHS access (sub-)tree as potentially written, even when the RHS access describing this level is not, because some of its sub-accesses might be, which is exactly what happens in the PR. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2017-10-02 Martin Jambor PR tree-optimization/82363 * tree-sra.c (propagate_subaccesses_across_link): In unrecoverable mismatch, mark lacc written regardless of racc. testsuite/ * gcc.dg/tree-ssa/pr82363.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/pr82363.c | 50 +++++++++++++++++++++++++++++++++ gcc/tree-sra.c | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82363.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c new file mode 100644 index 00000000000..6652468976b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c @@ -0,0 +1,50 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +struct A +{ + int b; + int c; + int d; +}; + +struct E +{ + int f; + int g:18; + struct A h; +}; + +struct I +{ + int b; + int j; + struct E k; +}; + +int l, *m = &l; + +struct A n; +struct I o; + +void __attribute__ ((noipa)) +test_l (void) +{ + if (l != 1) + __builtin_abort (); +} + +int main () +{ + while (1) + { + struct I q = { 0, 0, {0, 0, {1, 1, 1}}}, p = q, r = p, *s = &q; + if (p.k.h.c) + o = p; + *m = r.k.h.d; + n = (*s).k.h; + break; + } + test_l (); + return 0; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index f5675edc7f1..bac593951e7 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2691,7 +2691,7 @@ propagate_subaccesses_across_link (struct access *lacc, struct access *racc) } else { - if (rchild->grp_write && !lacc->grp_write) + if (!lacc->grp_write) { ret = true; subtree_mark_written_and_enqueue (lacc);