From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23033 invoked by alias); 2 Jun 2017 07:14:31 -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 22926 invoked by uid 89); 2 Jun 2017 07:14:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Jun 2017 07:14:22 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D9F5232053; Fri, 2 Jun 2017 07:14:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D9F5232053 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D9F5232053 Received: from tucnak.zalov.cz (unknown [10.36.118.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2FD081800C; Fri, 2 Jun 2017 07:14:24 +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 v527EIeY000933; Fri, 2 Jun 2017 09:14:20 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v527EGfU000931; Fri, 2 Jun 2017 09:14:16 +0200 Date: Fri, 02 Jun 2017 07:14:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix RTL sharing bug (PR rtl-optimization/80903) Message-ID: <20170602071416.GM24023@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00094.txt.bz2 Hi! As has been mentioned earlier, when the doloop code uses the expander after expansion, we need to unshare stuff because the expander relies on unsharing being done after it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-06-02 Jakub Jelinek PR rtl-optimization/80903 * loop-doloop.c (add_test): Unshare sequence. * gcc.dg/pr80903.c: New test. --- gcc/loop-doloop.c.jj 2017-03-24 14:36:35.000000000 +0100 +++ gcc/loop-doloop.c 2017-05-29 12:40:39.062107631 +0200 @@ -367,6 +367,7 @@ add_test (rtx cond, edge *e, basic_block } seq = get_insns (); + unshare_all_rtl_in_chain (seq); end_sequence (); /* There always is at least the jump insn in the sequence. */ --- gcc/testsuite/gcc.dg/pr80903.c.jj 2017-05-29 12:40:27.988242239 +0200 +++ gcc/testsuite/gcc.dg/pr80903.c 2017-05-29 12:37:39.000000000 +0200 @@ -0,0 +1,34 @@ +/* PR rtl-optimization/80903 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -funroll-loops" } */ + +short int a; + +void +foo (int x, short int y, short int z) +{ + if (y != 0) + { + const short int b = 37; + y = 0; + while (y < b) + { + while (y < b) + { + lab: + ++y; + } + for (y = 0; y < b - 1; ++y) + ; + if (z != 0) + { + --a; + y *= a; + } + z = x; + } + x = 0; + } + + goto lab; +} Jakub