From patchwork Mon Sep 20 13:42:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 65209 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 1EB33B6EF7 for ; Mon, 20 Sep 2010 23:42:10 +1000 (EST) Received: (qmail 28902 invoked by alias); 20 Sep 2010 13:42:07 -0000 Received: (qmail 28885 invoked by uid 22791); 20 Sep 2010 13:42:06 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Mon, 20 Sep 2010 13:42:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8KDfl5g010371 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Sep 2010 09:41:47 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8KDfk05013587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 20 Sep 2010 09:41:46 -0400 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 o8KDgqkn007149; Mon, 20 Sep 2010 15:42:52 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o8KDgoRw007148; Mon, 20 Sep 2010 15:42:50 +0200 Date: Mon, 20 Sep 2010 15:42:50 +0200 From: Jakub Jelinek To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix combiner i3/i2 pattern splitting (PR rtl-optimization/45695, take 2) Message-ID: <20100920134250.GN1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20100917143430.GC1269@tyan-ft48-01.lab.bos.redhat.com> <201009181823.45528.ebotcazou@adacore.com> <20100920102901.GJ1269@tyan-ft48-01.lab.bos.redhat.com> <201009201320.01415.ebotcazou@adacore.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201009201320.01415.ebotcazou@adacore.com> User-Agent: Mutt/1.5.20 (2009-12-10) 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 Mon, Sep 20, 2010 at 01:20:01PM +0200, Eric Botcazou wrote: > > The following patch just fixes the HAVE_cc0 case then and does the removal. > > It will enable more combining for all targets though, won't it? If so, I > think that it isn't appropriate for the branch. Just replace the 'break' > with 'undo_all + return' there (and add the missing call to use_crosses_set_p > for cc0 targets if you want). So this for 4.5 branch instead? 2010-09-20 Jakub Jelinek PR rtl-optimization/45695 * combine.c (try_combine): Don't try to swap the two patterns, if the chosen order is not possible, just give up. For HAVE_cc0 targets, check if XVECEXP (newpat, 0, 0) doesn't use REGs or MEMs set by insns in between i2 and i3. * gcc.c-torture/execute/pr45695.c: New test. Jakub --- gcc/combine.c.jj 2010-09-20 15:26:42.420457795 +0200 +++ gcc/combine.c 2010-09-20 15:35:17.249646756 +0200 @@ -3531,6 +3531,12 @@ try_combine (rtx i3, rtx i2, rtx i1, int #ifdef HAVE_cc0 if (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0))) { + if (use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 0)), + DF_INSN_LUID (i2))) + { + undo_all (); + return 0; + } newi2pat = XVECEXP (newpat, 0, 0); newpat = XVECEXP (newpat, 0, 1); } @@ -3554,44 +3560,11 @@ try_combine (rtx i3, rtx i2, rtx i1, int { rtx reg = XEXP (XVECEXP (newi2pat, 0, i), 0); if (reg_overlap_mentioned_p (reg, newpat)) - break; + { + undo_all (); + return 0; + } } - - if (i >= 0) - { - /* CLOBBERs on newi2pat prevent it going first. - Try the other order of the insns if possible. */ - temp = newpat; - newpat = XVECEXP (newi2pat, 0, 0); - newi2pat = temp; -#ifdef HAVE_cc0 - if (reg_referenced_p (cc0_rtx, newpat)) - { - undo_all (); - return 0; - } -#endif - - i2_code_number = recog_for_combine (&newi2pat, i2, - &new_i2_notes); - if (i2_code_number < 0) - { - undo_all (); - return 0; - } - - if (GET_CODE (newi2pat) == PARALLEL) - for (i = XVECLEN (newi2pat, 0) - 1; i >= 0; i--) - if (GET_CODE (XVECEXP (newi2pat, 0, i)) == CLOBBER) - { - rtx reg = XEXP (XVECEXP (newi2pat, 0, i), 0); - if (reg_overlap_mentioned_p (reg, newpat)) - { - undo_all (); - return 0; - } - } - } } insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes); --- gcc/testsuite/gcc.c-torture/execute/pr45695.c.jj 2010-09-20 15:33:11.081489086 +0200 +++ gcc/testsuite/gcc.c-torture/execute/pr45695.c 2010-09-20 15:33:11.082656001 +0200 @@ -0,0 +1,32 @@ +/* PR rtl-optimization/45695 */ + +extern void abort (void); + +__attribute__((noinline)) void +g (int x) +{ + asm volatile ("" : "+r" (x)); +} + +__attribute__((noinline)) int +f (int a, int b, int d) +{ + int r = -1; + b += d; + if (d == a) + r = b - d; + g (b); + return r; +} + +int +main (void) +{ + int l; + asm ("" : "=r" (l) : "0" (0)); + if (f (l + 0, l + 1, l + 4) != -1) + abort (); + if (f (l + 4, l + 1, l + 4) != 1) + abort (); + return 0; +}