From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74144 invoked by alias); 2 Dec 2017 07:55:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 74124 invoked by uid 89); 2 Dec 2017 07:55:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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; Sat, 02 Dec 2017 07:55:03 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A3207ADD8; Sat, 2 Dec 2017 07:55:01 +0000 (UTC) Date: Sat, 02 Dec 2017 07:55:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: <20171201223619.GA2353@tucnak> References: <20171201223619.GA2353@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] Fix store-merging vuse handling (PR tree-optimization/83170, PR tree-optimization/83241) To: Jakub Jelinek CC: gcc-patches@gcc.gnu.org From: Richard Biener Message-ID: <389688A2-E5DE-4994-8E27-47FF85D4B613@suse.de> X-SW-Source: 2017-12/txt/msg00094.txt.bz2 On December 1, 2017 11:36:19 PM GMT+01:00, Jakub Jelinek = wrote: >Hi! > >The bswap infrastructure uses the vuse field to make sure all the loads >are >having the same gimple_vuse and also uses it in bswap_replace. >When this infrastructure is used inside of the store-merging pass, the >problem is that the old stores are being removed and new added, so >gimple_vuse of the loads we record during process_stmt can change. >So, this patch updates the vuse fields before we plan to use it (in >try_coalesce_bswap for the checking and in output_merged_stores for the >bswap_replace purposes). > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK.=20 Richard.=20 >2017-12-01 Jakub Jelinek > > PR tree-optimization/83170 > PR tree-optimization/83241 > * gimple-ssa-store-merging.c > (imm_store_chain_info::try_coalesce_bswap): Update vuse field from > gimple_vuse (ins_stmt) in case it has changed. > (imm_store_chain_info::output_merged_store): Likewise. > > * gcc.dg/store_merging_17.c: New test. > >--- gcc/gimple-ssa-store-merging.c.jj 2017-12-01 09:17:36.000000000 >+0100 >+++ gcc/gimple-ssa-store-merging.c 2017-12-01 16:03:40.806918965 +0100 >@@ -2384,6 +2384,9 @@ imm_store_chain_info::try_coalesce_bswap > this_n.type =3D type; > if (!this_n.base_addr) > this_n.range =3D try_size / BITS_PER_UNIT; >+ else >+ /* Update vuse in case it has changed by output_merged_stores. */ >+ this_n.vuse =3D gimple_vuse (info->ins_stmt); > unsigned int bitpos =3D info->bitpos - infof->bitpos; > if (!do_shift_rotate (LSHIFT_EXPR, &this_n, > BYTES_BIG_ENDIAN >@@ -3341,10 +3344,16 @@ imm_store_chain_info::output_merged_stor > we've checked the aliasing already in try_coalesce_bswap and > we want to sink the need load into seq. So need to use new_vuse > on the load. */ >- if (n->base_addr && n->vuse =3D=3D NULL) >+ if (n->base_addr) > { >- n->vuse =3D new_vuse; >- ins_stmt =3D NULL; >+ if (n->vuse =3D=3D NULL) >+ { >+ n->vuse =3D new_vuse; >+ ins_stmt =3D NULL; >+ } >+ else >+ /* Update vuse in case it has changed by output_merged_stores.=20 >*/ >+ n->vuse =3D gimple_vuse (ins_stmt); > } > bswap_res =3D bswap_replace (gsi_start (seq), ins_stmt, fndecl, > bswap_type, load_type, n, bswap); >--- gcc/testsuite/gcc.dg/store_merging_17.c.jj 2017-12-01 >16:07:20.590224536 +0100 >+++ gcc/testsuite/gcc.dg/store_merging_17.c 2017-12-01 >16:07:01.000000000 +0100 >@@ -0,0 +1,17 @@ >+/* PR tree-optimization/83241 */ >+/* { dg-do compile { target store_merge } } */ >+/* { dg-options "-O2" } */ >+ >+struct S { int a; short b[32]; } e; >+struct T { volatile int c; int d; } f; >+ >+void >+foo () >+{ >+ struct T g =3D f; >+ e.b[0] =3D 6; >+ e.b[1] =3D 6; >+ e.b[4] =3D g.d; >+ e.b[5] =3D g.d >> 16; >+ e.a =3D 1; >+} > > Jakub