From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26018 invoked by alias); 11 Aug 2007 13:09:34 -0000 Received: (qmail 25944 invoked by uid 22791); 11 Aug 2007 13:09:33 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 11 Aug 2007 13:09:31 +0000 Received: (qmail 28270 invoked from network); 11 Aug 2007 13:09:29 -0000 Received: from unknown (HELO gateway) (10.0.0.100) by mail.codesourcery.com with SMTP; 11 Aug 2007 13:09:29 -0000 Received: by gateway (Postfix, from userid 1010) id 7E41C6C130; Sat, 11 Aug 2007 06:09:29 -0700 (PDT) From: Richard Sandiford To: Ian Lance Taylor Mail-Followup-To: Ian Lance Taylor ,gcc-patches@gcc.gnu.org, richard@codesourcery.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [tree->rtl] Fix execute/20041124-1.c for SH PIC References: <87abszb5sl.fsf@firetop.home> Date: Sat, 11 Aug 2007 13:09:00 -0000 In-Reply-To: (Ian Lance Taylor's message of "10 Aug 2007 17\:33\:26 -0700") Message-ID: <87r6maqktz.fsf@firetop.home> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg00732.txt.bz2 Ian Lance Taylor writes: > Richard Sandiford writes: >> - if (REG_P (valreg) >> - && HARD_REGISTER_P (valreg) >> - && CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (REGNO (valreg))) >> - && !(REG_P (target) && !HARD_REGISTER_P (target))) >> - valreg = copy_to_reg (valreg); >> + valreg = avoid_likely_spilled_reg (valreg); > > You've dropped the test of whether TARGET is a hard register. Why? > It's probably OK to drop that when you have a complex mode, but you've > dropped it in all cases. Plain carelessness, sorry. I meant to keep that check when I was weighing up this approach vs the combine one, but forgot when I wrote the patch. Is the version below OK? Re-bootstrapped & regression-tested on x86_64-linux-gnu, and regression-tested on sh-elf. Richard gcc/ * calls.c (avoid_likely_spilled_reg): New function. (expand_call): Use it. Index: gcc/calls.c =================================================================== --- gcc/calls.c (revision 127336) +++ gcc/calls.c (working copy) @@ -1856,6 +1856,31 @@ shift_return_value (enum machine_mode mo return true; } +/* If X is a likely-spilled register value, copy it to a pseudo + register and return that register. Return X otherwise. */ + +static rtx +avoid_likely_spilled_reg (rtx x) +{ + rtx new; + + if (REG_P (x) + && HARD_REGISTER_P (x) + && CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (REGNO (x)))) + { + /* Make sure that we generate a REG rather than a CONCAT. + Moves into CONCATs can need nontrivial instructions, + and the whole point of this function is to avoid + using the hard register directly in such a situation. */ + generating_concat_p = 0; + new = gen_reg_rtx (GET_MODE (x)); + generating_concat_p = 1; + emit_move_insn (new, x); + return new; + } + return x; +} + /* Generate all the code for a CALL_EXPR exp and return an rtx for its value. Store the value in TARGET (specified as an rtx) if convenient. @@ -2953,11 +2978,8 @@ expand_call (tree exp, rtx target, int i /* We have to copy a return value in a CLASS_LIKELY_SPILLED hard reg to a plain register. */ - if (REG_P (valreg) - && HARD_REGISTER_P (valreg) - && CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (REGNO (valreg))) - && !(REG_P (target) && !HARD_REGISTER_P (target))) - valreg = copy_to_reg (valreg); + if (!REG_P (target) || HARD_REGISTER_P (target)) + valreg = avoid_likely_spilled_reg (valreg); /* If TARGET is a MEM in the argument area, and we have saved part of the argument area, then we can't store @@ -3002,7 +3024,7 @@ expand_call (tree exp, rtx target, int i sibcall_failure = 1; } else - target = copy_to_reg (valreg); + target = copy_to_reg (avoid_likely_spilled_reg (valreg)); if (targetm.calls.promote_function_return(funtype)) {