From patchwork Wed Sep 6 09:15:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 810459 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-461559-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="M4ha1JhL"; 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 3xnHxc1lNtz9sRV for ; Wed, 6 Sep 2017 19:15:47 +1000 (AEST) 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=l/1R1hVzcgD6GMJGGBiJs61+wKvlSH1pe/dOZlYbb/TSnkwozi hapZXsW9/7V8PUh0C7Nf9pGSu1Bb0KjttGYtncGdFHDNkqzo6/jnxQ0c5iVrI4B1 +EFScpoJ5pxweXiLQm6ekoTGa1nrg3h3eFYEUJJ3QEmB24h5TudA/DHzs= 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=yZFlnVSkz0eC1kSAHoibhj1teuQ=; b=M4ha1JhLBLG7R1WdAgqm p6Hi5+ZT4qM+FP2dVKXK5/QmMrKHKQ/rKrcP2hgdgMcxDd8nbwwCcbAVETnPl41y +lGuNvkp+1IgCBqJpxwwZqqGVQWAAuWccKgfcMENpifYmD51SESPmaWyXwVuGLG0 THaGrRSZl44nEtbeVlbcIng= Received: (qmail 29079 invoked by alias); 6 Sep 2017 09:15:38 -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 27571 invoked by uid 89); 6 Sep 2017 09:15:37 -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=Let's, representative 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; Wed, 06 Sep 2017 09:15:36 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 45E41AE73 for ; Wed, 6 Sep 2017 09:15:34 +0000 (UTC) Date: Wed, 6 Sep 2017 11:15:33 +0200 From: Martin Jambor To: GCC Patches Cc: Richard Biener Subject: [PR 82078] Enqueue all SRA links for write flag propagation Message-ID: <20170906091533.t6r3gatru4pn4vtc@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, PR 82078 is another fallout from lazy setting of written flag in SRA. The problem here is that we do not enqueue assignment links going out of accesses of candidates that were disqualified before we start the loop with sort_and_splice_var_accesses. Given that the propagation is now a correctness necessity, we need to enqueue all links for processing, so this patch does it when they they are created. There should be very little extra work done because of this because propagate_all_subaccesses starts with checking the candidate-status of both sides of each link and acts accordingly. Bootstrapped and tested on x86_64-linux without any issues. OK for trunk? Thanks, Martin 2017-09-05 Martin Jambor PR tree-optimization/82078 gcc/ * tree-sra.c (sort_and_splice_var_accesses): Move call to add_access_to_work_queue... (build_accesses_from_assign): ...here. (propagate_all_subaccesses): Make sure racc is the group representative, if there is one. gcc/testsuite/ * gcc.dg/tree-ssa/pr82078.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/pr82078.c | 27 +++++++++++++++++++++++++++ gcc/tree-sra.c | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82078.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82078.c b/gcc/testsuite/gcc.dg/tree-ssa/pr82078.c new file mode 100644 index 00000000000..3774986324b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82078.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +struct S0 { + signed f4; + signed f9 : 5; +} a[6][5], b = {2} + +; +int c, d; +int fn1() { + struct S0 e[5][6]; + struct S0 f; + b = f = e[2][5] = a[5][0]; + if (d) + ; + else + return f.f9; + e[c][45] = a[4][4]; +} + +int main() { + fn1(); + if (b.f4 != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 68edbce21b3..163b7a2d03b 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1359,6 +1359,8 @@ build_accesses_from_assign (gimple *stmt) link->lacc = lacc; link->racc = racc; add_link_to_rhs (racc, link); + add_access_to_work_queue (racc); + /* Let's delay marking the areas as written until propagation of accesses across link, unless the nature of rhs tells us that its data comes from elsewhere. */ @@ -2118,7 +2120,6 @@ sort_and_splice_var_accesses (tree var) access->grp_total_scalarization = total_scalarization; access->grp_partial_lhs = grp_partial_lhs; access->grp_unscalarizable_region = unscalarizable_region; - add_access_to_work_queue (access); *prev_acc_ptr = access; prev_acc_ptr = &access->next_grp; @@ -2712,6 +2713,8 @@ propagate_all_subaccesses (void) struct access *racc = pop_access_from_work_queue (); struct assign_link *link; + if (racc->group_representative) + racc= racc->group_representative; gcc_assert (racc->first_link); for (link = racc->first_link; link; link = link->next)