From patchwork Wed Nov 7 22:11:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 197733 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 E84A12C00AE for ; Thu, 8 Nov 2012 09:12:12 +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=1352931133; 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=Ze/x0kE izTJOI9aaCcW66Pj4jr8=; b=dAraKzKDOrblZWL2KzlcSPdxDONchjBl1gzA9lK yXyktRNq4Jdpe4xrhjMn5YVx/Byc/zR9cFk0y4xJgFZI88soEGV03L6KffuUTJEU A5GgPLr7srC8BqqmC28vDxOHy+AotG82F+qc0FH73UIbVeHdWBiMuHhW2PHqKG2h xzSs= 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=Y/0aWFSsh+9Z2DjtxNsNF+247iNKwPcSxM+ioHN64reQ+efUvdclVGAWfKwvse cm/ATm8UB5lc1RulUzia92P4NV0CbjVtpP+SjxqAJtH/dX9wEosDam08F+pyzUjt 3SUUEOj4OhX41iQO6y+F/43JM+GQnKQb78mNapgQoT9hg=; Received: (qmail 24081 invoked by alias); 7 Nov 2012 22:12:09 -0000 Received: (qmail 24070 invoked by uid 22791); 7 Nov 2012 22:12:08 -0000 X-SWARE-Spam-Status: No, hits=-6.6 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; Wed, 07 Nov 2012 22:12:00 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA7MC0ue000506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Nov 2012 17:12:00 -0500 Received: from Mair.local (vpn-11-127.rdu.redhat.com [10.11.11.127]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qA7MBwCl025800 for ; Wed, 7 Nov 2012 17:11:59 -0500 Message-ID: <509ADCAE.4060907@redhat.com> Date: Wed, 07 Nov 2012 17:11:58 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR55122 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=55122 The problem was in generation of reload pseudo for matching operands with uniq value which prevented to assign the same hard register for the reload pseudo and the original input pseudo when the choice of hard regs was quite small (AD regs). The patch was successfully bootstrapped and tested on x86/x86-64. Committed as rev. 193310. 2012-11-07 Vladimir Makarov PR rtl-optimization/55122 * lra-constraints.c (match_reload): Sync values for dead input pseudos. 2012-11-07 Vladimir Makarov PR rtl-optimization/55122 * gcc.dg/pr55122.c: New test. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 193303) +++ lra-constraints.c (working copy) @@ -682,6 +682,11 @@ match_reload (signed char out, signed ch new_out_reg = gen_lowpart_SUBREG (outmode, reg); else new_out_reg = gen_rtx_SUBREG (outmode, reg, 0); + /* If the input reg is dying here, we can use the same hard + register for REG and IN_RTX. */ + if (REG_P (in_rtx) + && find_regno_note (curr_insn, REG_DEAD, REGNO (in_rtx))) + lra_reg_info[REGNO (reg)].val = lra_reg_info[REGNO (in_rtx)].val; } else { @@ -698,6 +703,19 @@ match_reload (signed char out, signed ch it at the end of LRA work. */ clobber = emit_clobber (new_out_reg); LRA_TEMP_CLOBBER_P (PATTERN (clobber)) = 1; + if (GET_CODE (in_rtx) == SUBREG) + { + rtx subreg_reg = SUBREG_REG (in_rtx); + + /* If SUBREG_REG is dying here and sub-registers IN_RTX + and NEW_IN_REG are similar, we can use the same hard + register for REG and SUBREG_REG. */ + if (REG_P (subreg_reg) && GET_MODE (subreg_reg) == outmode + && SUBREG_BYTE (in_rtx) == SUBREG_BYTE (new_in_reg) + && find_regno_note (curr_insn, REG_DEAD, REGNO (subreg_reg))) + lra_reg_info[REGNO (reg)].val + = lra_reg_info[REGNO (subreg_reg)].val; + } } } else Index: testsuite/gcc.dg/pr55122.c =================================================================== --- testsuite/gcc.dg/pr55122.c (revision 0) +++ testsuite/gcc.dg/pr55122.c (working copy) @@ -0,0 +1,14 @@ +/* PR rtl-optimization/55122 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int i, a; +unsigned long long b; + +void f(void) +{ + for(i = 0; i < 15; i++) + b *= b; + + b *= a ? 0 : b; +}