From patchwork Mon Nov 7 12:19:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 691874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tCBMf3qBKz9t1T for ; Mon, 7 Nov 2016 23:19:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="frwINm23"; dkim-atps=neutral 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=noBKURBCaZYeecGOAois4Dwwqmhw0fdQgJtFkqQ+bDLm3T+YHP6aP czIvoOvGMz1TDlNDhmSK47oX4tqe60ZfMpplgOv1cc20nLOALEZ3HwaKqHl2SmL7 qzRxOSXtt9oaSlg11jdxxV7k9golt6AEnSU3QeEj+1/Pg1FqvgjBys= 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:subject:message-id:mime-version:content-type; s= default; bh=zg27fqd2lWZGbcRzWCZ7ypzNKI4=; b=frwINm23isxiYvt9tTxG WMuEwyIYwH6rHgp2Tiw2Ik1KRMPwXQ9uM2M3eym40JCl/lGa0Ee7ZIPY/eMwI3t8 1zB9uokBEdRNA+P8yD/8msS++6wsmOka1U1P7Sh5dTPnYl4TnglFBCvAvXUIQ3lz kjiZTNrpJcpOojkQZj+7le0= Received: (qmail 36927 invoked by alias); 7 Nov 2016 12:19:34 -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 36917 invoked by uid 89); 7 Nov 2016 12:19:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:tree_op, 7887 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, 07 Nov 2016 12:19:23 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CE8C3ACA5 for ; Mon, 7 Nov 2016 12:19:21 +0000 (UTC) Date: Mon, 7 Nov 2016 13:19:21 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR78218 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2016-11-07 Richard Biener PR tree-optimization/78218 * gimple-ssa-store-merging.c (pass_store_merging::terminate_all_aliasing_chains): Drop unused argument, fix alias check to also consider uses. (pass_store_merging::execute): Adjust. * gcc.dg/torture/pr78218.c: New testcase. Index: gcc/gimple-ssa-store-merging.c =================================================================== --- gcc/gimple-ssa-store-merging.c (revision 241893) +++ gcc/gimple-ssa-store-merging.c (working copy) @@ -726,7 +726,7 @@ private: hash_map m_stores; bool terminate_and_process_all_chains (); - bool terminate_all_aliasing_chains (tree, imm_store_chain_info **, + bool terminate_all_aliasing_chains (imm_store_chain_info **, bool, gimple *); bool terminate_and_release_chain (imm_store_chain_info *); }; // class pass_store_merging @@ -755,8 +755,7 @@ pass_store_merging::terminate_and_proces If that is the case we have to terminate any chain anchored at BASE. */ bool -pass_store_merging::terminate_all_aliasing_chains (tree dest, - imm_store_chain_info +pass_store_merging::terminate_all_aliasing_chains (imm_store_chain_info **chain_info, bool var_offset_p, gimple *stmt) @@ -788,7 +787,10 @@ pass_store_merging::terminate_all_aliasi unsigned int i; FOR_EACH_VEC_ELT ((*chain_info)->m_store_info, i, info) { - if (stmt_may_clobber_ref_p (info->stmt, dest)) + if (ref_maybe_used_by_stmt_p (stmt, + gimple_assign_lhs (info->stmt)) + || stmt_may_clobber_ref_p (stmt, + gimple_assign_lhs (info->stmt))) { if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1458,7 +1460,7 @@ pass_store_merging::execute (function *f } /* Store aliases any existing chain? */ - terminate_all_aliasing_chains (lhs, chain_info, false, stmt); + terminate_all_aliasing_chains (chain_info, false, stmt); /* Start a new chain. */ struct imm_store_chain_info *new_chain = new imm_store_chain_info (base_addr); @@ -1477,13 +1479,13 @@ pass_store_merging::execute (function *f } } else - terminate_all_aliasing_chains (lhs, chain_info, + terminate_all_aliasing_chains (chain_info, offset != NULL_TREE, stmt); continue; } - terminate_all_aliasing_chains (NULL_TREE, NULL, false, stmt); + terminate_all_aliasing_chains (NULL, false, stmt); } terminate_and_process_all_chains (); } Index: gcc/testsuite/gcc.dg/torture/pr78218.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr78218.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr78218.c (working copy) @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +struct +{ + int v; +} a[2]; + +int b; + +void __attribute__((noinline,noclone)) +check () +{ + if (a[0].v != 1) + __builtin_abort (); +} + +int main () +{ + a[1].v = 1; + a[0] = a[1]; + a[1].v = 0; + check (a); + return 0; +}