This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch i386]: Expand sibling-tail-calls via accumulator register
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Kai Tietz <ktietz at redhat dot com>
- Cc: Jeff Law <law at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Henderson <rth at redhat dot com>
- Date: Mon, 26 May 2014 20:32:08 +0200
- Subject: Re: [patch i386]: Expand sibling-tail-calls via accumulator register
- Authentication-results: sourceware.org; auth=none
- References: <356718653 dot 5712706 dot 1400794422397 dot JavaMail dot zimbra at redhat dot com> <CAMe9rOrCiRSTA+4jiGeQLub4P--KX8XzkYiwAVWZUxzunhvkPQ at mail dot gmail dot com> <537F8DC7 dot 3090906 at redhat dot com> <777706000 dot 8424762 dot 1401128436051 dot JavaMail dot zimbra at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, May 26, 2014 at 02:20:36PM -0400, Kai Tietz wrote:
> --- i386.c (revision 210936)
> +++ i386.c (working copy)
> @@ -5298,6 +5298,12 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
> decl_or_type = type;
> }
>
> + /* We need to reject stdarg-function for x86_64 ABI as accumulator
> + is used as argument. */
> + if (TARGET_64BIT && stdarg_p (type)
> + && ix86_function_type_abi (type) == SYSV_ABI)
> + return false;
> +
> /* Check that the return value locations are the same. Like
> if we are returning floats on the 80387 register stack, we cannot
> make a sibcall from a function that doesn't return a float to a
> @@ -24916,8 +24922,19 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx call
> ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode)
> : !call_insn_operand (XEXP (fnaddr, 0), word_mode))
> {
> + rtx r;
> fnaddr = convert_to_mode (word_mode, XEXP (fnaddr, 0), 1);
> - fnaddr = gen_rtx_MEM (QImode, copy_to_mode_reg (word_mode, fnaddr));
> + if (!sibcall)
> + r = copy_to_mode_reg (word_mode, fnaddr);
> + else
> + {
> + r = gen_rtx_REG (word_mode, AX_REG);
> + if (! general_operand (fnaddr, VOIDmode))
> + fnaddr = force_operand (fnaddr, r);
Wrong formatting.
> + if (fnaddr != r)
> + emit_move_insn (r, fnaddr);
> + }
> + fnaddr = gen_rtx_MEM (QImode, r);
> }
>
> call = gen_rtx_CALL (VOIDmode, fnaddr, callarg1);
In any case, I still can't understand how limiting the choices of the
register allocator can improve code rather than making it worse.
If the accumulator is available there, why doesn't the RA choose it
if it is beneficial? And why aren't other registers similarly suitable for
that? Say r10, r11...
Jakub