From patchwork Fri Feb 3 12:01:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 139361 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]) by ozlabs.org (Postfix) with SMTP id 68AB2104792 for ; Fri, 3 Feb 2012 23:02:19 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328875340; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=JfHDr0gawlLTKCfVdxS4/qvJz4Q=; b=la5vk2YdpVXgzN4 5YEi+T2JzMa1LasLzM9c76iVXODGal/k3c8Dpdy0ZakmKGc1bpQ6IBpNGVzPCkjV YYAlY03BAIjmJphMI6Pz6bohpfmZGgZmDshxlMEJYEQNvsJox2eaegqRuSljk+lO 5LrKYjcm5qrW+IT+zuIlmalySJa8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lFdd8VnuIcvib6NYNZCs4t0u1cWtiOGvMyEboIAk2vqnByL3tIKT9VPAx8NwwM 4st7vDe2EiN73oHMZ8qXjOxCBI6PFs5WVvW1PbOx02QxPAPryRY12IcqWnvjRM9o lUrgR0eTP+KdSGR7HpLL1v+S+BUMmJiuvAlDotmVwfcXI=; Received: (qmail 20059 invoked by alias); 3 Feb 2012 12:02:16 -0000 Received: (qmail 20050 invoked by uid 22791); 3 Feb 2012 12:02:15 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Feb 2012 12:01:51 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q13C1RWg005885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Feb 2012 07:01:28 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q13C1Qnu004652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Feb 2012 07:01:27 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id q13C1Ooc026569; Fri, 3 Feb 2012 13:01:24 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id q13C1MwY026568; Fri, 3 Feb 2012 13:01:22 +0100 Date: Fri, 3 Feb 2012 13:01:22 +0100 From: Jakub Jelinek To: Zdenek Dvorak Cc: Eric Botcazou , Richard Guenther , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix RTL sharing bug in loop unswitching (PR rtl-optimization/52092) Message-ID: <20120203120122.GF18768@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20120202191227.GA18768@tyan-ft48-01.lab.bos.redhat.com> <20120203081723.GA28259@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120203081723.GA28259@kam.mff.cuni.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 On Fri, Feb 03, 2012 at 09:17:23AM +0100, Zdenek Dvorak wrote: > > It seems loop-iv.c happily creates shared RTL in lots of places, > > loop-unroll.c solves that by unsharing everything it adds, this is > > an attempt to do the same in unswitching to unshare everything iv_analyze > > came up with. > > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > I would suggest to move the unsharing to the point where it is clear that > the rtl will added, i.e., > > loop-unswitch.c:370 > nloop = unswitch_loop (loop, bbs[i], cond, cinsn); > -> > nloop = unswitch_loop (loop, bbs[i], copy_rtx_if_shared (cond), cinsn); You're right, and that also cures the thing that inner unswitch_single_loop might use again a condition based on the same rtl (or reverse_condition thereof). Bootstrapped/regtested again on x86_64-linux and i686-linux, approved by Richard on IRC, committed to trunk. Thanks. 2012-02-03 Jakub Jelinek Zdenek Dvorak PR rtl-optimization/52092 * loop-unswitch.c (unswitch_single_loop): Call copy_rtx_if_shared on get_iv_value result. * gcc.c-torture/compile/pr52092.c: New test. Jakub --- gcc/loop-unswitch.c.jj 2010-06-28 15:36:30.000000000 +0200 +++ gcc/loop-unswitch.c 2012-02-03 09:24:24.385450397 +0100 @@ -367,7 +367,7 @@ unswitch_single_loop (struct loop *loop, fprintf (dump_file, ";; Unswitching loop\n"); /* Unswitch the loop on this condition. */ - nloop = unswitch_loop (loop, bbs[i], cond, cinsn); + nloop = unswitch_loop (loop, bbs[i], copy_rtx_if_shared (cond), cinsn); gcc_assert (nloop); /* Invoke itself on modified loops. */ --- gcc/testsuite/gcc.c-torture/compile/pr52092.c.jj 2012-02-02 14:11:37.722031008 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr52092.c 2012-02-02 14:11:14.000000000 +0100 @@ -0,0 +1,25 @@ +/* PR rtl-optimization/52092 */ + +int a, b, c, d, e, f, g; + +void +foo (void) +{ + for (;;) + { + int *h = 0; + int i = 3; + int **j = &h; + if (e) + { + c = d || a; + g = c ? a : b; + if ((char) (i * g)) + { + h = &f; + *h = 0; + } + **j = 0; + } + } +}