From patchwork Tue Jul 27 09:41:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 59985 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 D2199B6EF1 for ; Tue, 27 Jul 2010 19:41:49 +1000 (EST) Received: (qmail 19426 invoked by alias); 27 Jul 2010 09:41:47 -0000 Received: (qmail 19418 invoked by uid 22791); 27 Jul 2010 09:41:46 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Jul 2010 09:41:41 +0000 Received: (qmail 25704 invoked from network); 27 Jul 2010 09:41:39 -0000 Received: from unknown (HELO ?84.152.198.157?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Jul 2010 09:41:39 -0000 Message-ID: <4C4EA9C3.8080405@codesourcery.com> Date: Tue, 27 Jul 2010 11:41:23 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100724 Thunderbird/3.1.1 MIME-Version: 1.0 To: GCC Patches Subject: Fix PR45051 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 IRA patch last week exposed a reload problem on cris. For some reason the port seems to be generating too many reloads when subregs of DImode values are involved, but that's something for the port maintainers to look at. It exposed a problem in delete_output_reload where we have (set (reg:SI 0) (...)) ; insn, r0 is the reload register (set (reg:SI 9) (reg:SI 0)) ; output reload for (subreg (reg x) 4) (set (mem:DI z) (reg 8)) ; DImode reg x got hard reg 8. ... (set (something) (reg:SI 0)) ; inheriting reg 0 for reloading part of X (reg_dead x) Here, we delete the output reload insn, because we can't see that the store to memory uses reg 9: reg_mentioned_p doesn't take hard regs with multiple words into account. Fixed with this patch; bootstrapped and regression tested on i686-linux and committed. Bernd PR rtl-optimization/45051 * reload1.c (delete_output_reload): Use refers_to_regno_p rather than reg_mentioned_p. Index: reload1.c =================================================================== --- reload1.c (revision 162421) +++ reload1.c (working copy) @@ -8813,6 +8813,8 @@ delete_output_reload (rtx insn, int j, i int n_inherited = 0; rtx i1; rtx substed; + unsigned regno; + int nregs; /* It is possible that this reload has been only used to set another reload we eliminated earlier and thus deleted this instruction too. */ @@ -8864,6 +8866,12 @@ delete_output_reload (rtx insn, int j, i if (n_occurrences > n_inherited) return; + regno = REGNO (reg); + if (regno >= FIRST_PSEUDO_REGISTER) + nregs = 1; + else + nregs = hard_regno_nregs[regno][GET_MODE (reg)]; + /* If the pseudo-reg we are reloading is no longer referenced anywhere between the store into it and here, and we're within the same basic block, then the value can only @@ -8875,7 +8883,7 @@ delete_output_reload (rtx insn, int j, i if (NOTE_INSN_BASIC_BLOCK_P (i1)) return; if ((NONJUMP_INSN_P (i1) || CALL_P (i1)) - && reg_mentioned_p (reg, PATTERN (i1))) + && refers_to_regno_p (regno, regno + nregs, PATTERN (i1), NULL)) { /* If this is USE in front of INSN, we only have to check that there are no more references than accounted for by inheritance. */