From patchwork Fri Mar 20 08:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1258705 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=dCDTEikQ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48kH2B1S8Pz9sPF for ; Fri, 20 Mar 2020 19:27:12 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C61193945C37; Fri, 20 Mar 2020 08:27:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C61193945C37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584692823; bh=pqvpqw4mS+kAACfPHj9YMsvg5F4Bcwco0q1wa3ShBVQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=dCDTEikQC4aG/ohxYizURpK6e7T7b8G6ZBduEd3hMypnXqwkicinFS93NiNxeadeU UsdXswwvQ1mkrRntpiItHyPumcVZH2e+7PMmzzIvcW7GiUYr8nJM81u8UkF+oOdU9d AvjQAQEljtOiujtxrO21zXMvHkQ0FJMihOMbZchk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by sourceware.org (Postfix) with ESMTP id 3FE0A3875DFD for ; Fri, 20 Mar 2020 08:27:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3FE0A3875DFD Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-xDxlfXG8Ne6LYDebXhoZLw-1; Fri, 20 Mar 2020 04:26:59 -0400 X-MC-Unique: xDxlfXG8Ne6LYDebXhoZLw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ECBF7107ACCA; Fri, 20 Mar 2020 08:26:57 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-22.ams2.redhat.com [10.36.112.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B7D65D9CA; Fri, 20 Mar 2020 08:26:57 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 02K8QtlG028459; Fri, 20 Mar 2020 09:26:55 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 02K8QsSD028458; Fri, 20 Mar 2020 09:26:54 +0100 Date: Fri, 20 Mar 2020 09:26:53 +0100 To: Richard Biener Subject: [PATCH] store-merging: Fix up -fnon-call-exceptions handling [PR94224] Message-ID: <20200320082653.GT2156@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! When we are adding a single store into a store group, we are already checking that store->lp_nr matches, but we have also code to add further INTEGER_CST stores into the group right away if the ordering requires that either we put there all or none from a certain set of stores. And in those cases we weren't doing these lp_nr checks, which means we could end up with stores with different lp_nr in the same group, which then ICEs during output_merged_store. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-03-20 Jakub Jelinek PR tree-optimization/94224 * gimple-ssa-store-merging.c (imm_store_chain_info::coalesce_immediate): Don't consider overlapping or adjacent INTEGER_CST rhs_code stores as mergeable if they have different lp_nr. * g++.dg/tree-ssa/pr94224.C: New test. Jakub --- gcc/gimple-ssa-store-merging.c.jj 2020-03-17 13:50:52.711936792 +0100 +++ gcc/gimple-ssa-store-merging.c 2020-03-19 17:37:06.218620323 +0100 @@ -2773,7 +2773,8 @@ imm_store_chain_info::coalesce_immediate break; if (info2->order < try_order) { - if (info2->rhs_code != INTEGER_CST) + if (info2->rhs_code != INTEGER_CST + || info2->lp_nr != merged_store->lp_nr) { /* Normally check_no_overlap makes sure this doesn't happen, but if end grows below, @@ -2791,6 +2792,7 @@ imm_store_chain_info::coalesce_immediate info2->bitpos + info2->bitsize); } else if (info2->rhs_code == INTEGER_CST + && info2->lp_nr == merged_store->lp_nr && !last_iter) { max_order = MAX (max_order, info2->order + 1); --- gcc/testsuite/g++.dg/tree-ssa/pr94224.C.jj 2020-03-19 17:45:38.306123576 +0100 +++ gcc/testsuite/g++.dg/tree-ssa/pr94224.C 2020-03-19 17:44:53.872774065 +0100 @@ -0,0 +1,34 @@ +// PR tree-optimization/94224 +// { dg-do compile } +// { dg-options "-O2 -fnon-call-exceptions -Wno-return-type" } + +void foo (int, int, long); + +static inline int +bar (int &x) +{ + x = 0; +} + +struct U +{ + int n, p; + long q; + bool *z; + int a; + U () : n (), z (), a (1) {} + ~U () { if (n) foo (p, n, q); } + void baz () { bar (a); } +}; + +struct W +{ + U w[2]; + W () { w[0].baz (); } +}; + +void +qux () +{ + new W; +}