From patchwork Fri Feb 8 22:05:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 219326 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 5E6EC2C0080 for ; Sat, 9 Feb 2013 09:06:17 +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=1360965978; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=XtXLEr7 DfzoCcB9OZVDVGX9AXSs=; b=vHxm0D5dE/TSbUpNyomq2xLmFxVeJnev+LUeXZQ rTnGKSJGFD7ridT2gngFE4hhtjj8q5pgdIUHmfKZJMt6+q0EeIwtedr+mDnOr6ld qV4ci7qUbZ+7K6iGoNIlHvES5S35B+DbpiP6UnBC0fiHirc+zE/2OBXWP/QtSTXC Swlw= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ULqtB2T0bdsYBzLvW4Gaqg+mwnPRLpNVxDtFwuJ01O2vBHmSCNZ8k+xNRj5R3U WT1qTgReL+MFjbh2sGY8h5azmp01lVY6v+oeaONeRCAQsjhjuCpfgu7Ee3ACDTsa OyGyxGDn3bxcKQisfduimsyQj7bkZ0+QUeXUoghJH2Aq0=; Received: (qmail 18802 invoked by alias); 8 Feb 2013 22:06:09 -0000 Received: (qmail 18773 invoked by uid 22791); 8 Feb 2013 22:06:08 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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, 08 Feb 2013 22:05:40 +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.14.4/8.14.4) with ESMTP id r18M5dbY003979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Feb 2013 17:05:39 -0500 Received: from Mair.local (vpn-49-198.rdu2.redhat.com [10.10.49.198]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r18M5cAE023776 for ; Fri, 8 Feb 2013 17:05:39 -0500 Message-ID: <511576B2.5020902@redhat.com> Date: Fri, 08 Feb 2013 17:05:38 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR56246 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 The following patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56246 LRA was not able to find enough regs for insn reloads. One reason of that was it did not try to reuse the same reload reg for the same value. Another reason was it tried to assign hard reg to a pseudo in any case, as the code account the pseudo as reload one and the pseudo is actually optional reload pseudo (the code lost track of this on the second constraint subpass iteration). The patch was bootstrapped and tested on x86/x86-64. Committed as rev. 195502. 2013-02-08 Vladimir Makarov PR rtl-optimization/56246 * lra-constraints.c (simplify_operand_subreg): Try tor reuse reload pseudo. * lra.c (lra): Clear lra_optional_reload_pseudos only when all constraints are satisfied. 2013-02-08 Vladimir Makarov PR rtl-optimization/56246 * gcc.target/i386/pr56246.c: New test. Index: lra.c =================================================================== --- lra.c (revision 195901) +++ lra.c (working copy) @@ -2272,7 +2272,6 @@ lra (FILE *f) { for (;;) { - bitmap_clear (&lra_optional_reload_pseudos); /* We should try to assign hard registers to scratches even if there were no RTL transformations in lra_constraints. */ @@ -2311,6 +2310,7 @@ lra (FILE *f) live_p = false; } } + bitmap_clear (&lra_optional_reload_pseudos); bitmap_clear (&lra_inheritance_pseudos); bitmap_clear (&lra_split_regs); if (! lra_need_for_spills_p ()) Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 195901) +++ lra-constraints.c (working copy) @@ -1213,24 +1213,26 @@ simplify_operand_subreg (int nop, enum m enum reg_class rclass = (enum reg_class) targetm.preferred_reload_class (reg, ALL_REGS); - new_reg = lra_create_new_reg_with_unique_value (reg_mode, reg, rclass, - "subreg reg"); - bitmap_set_bit (&lra_optional_reload_pseudos, REGNO (new_reg)); - if (type != OP_OUT - || GET_MODE_SIZE (GET_MODE (reg)) > GET_MODE_SIZE (mode)) + if (get_reload_reg (curr_static_id->operand[nop].type, reg_mode, reg, + rclass, "subreg reg", &new_reg)) { - push_to_sequence (before); - lra_emit_move (new_reg, reg); - before = get_insns (); - end_sequence (); - } - if (type != OP_IN) - { - start_sequence (); - lra_emit_move (reg, new_reg); - emit_insn (after); - after = get_insns (); - end_sequence (); + bitmap_set_bit (&lra_optional_reload_pseudos, REGNO (new_reg)); + if (type != OP_OUT + || GET_MODE_SIZE (GET_MODE (reg)) > GET_MODE_SIZE (mode)) + { + push_to_sequence (before); + lra_emit_move (new_reg, reg); + before = get_insns (); + end_sequence (); + } + if (type != OP_IN) + { + start_sequence (); + lra_emit_move (reg, new_reg); + emit_insn (after); + after = get_insns (); + end_sequence (); + } } SUBREG_REG (operand) = new_reg; lra_process_new_insns (curr_insn, before, after, Index: testsuite/gcc.target/i386/pr56246.c =================================================================== --- testsuite/gcc.target/i386/pr56246.c (revision 0) +++ testsuite/gcc.target/i386/pr56246.c (working copy) @@ -0,0 +1,7 @@ +/* PR target/56225 */ +/* { dg-do compile { target { ia32 } } } */ +/* { dg-options "-O2 -fno-omit-frame-pointer -march=i686 -fpic" } */ + +void NoBarrier_AtomicExchange (long long *ptr) { + while (__sync_val_compare_and_swap (ptr, 1, 0) ); +}