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: Richard Henderson <rth at redhat dot com>
- To: Jeff Law <law at redhat dot com>, Kai Tietz <ktietz at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 27 May 2014 09:22:05 -0700
- 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> <20140526183208 dot GG10386 at tucnak dot redhat dot com> <1487116948 dot 8449887 dot 1401132170121 dot JavaMail dot zimbra at redhat dot com> <20140526193543 dot GH10386 at tucnak dot redhat dot com> <625132578 dot 8474723 dot 1401136339171 dot JavaMail dot zimbra at redhat dot com> <5384B1BB dot 4080000 at redhat dot com>
On 05/27/2014 08:39 AM, Jeff Law wrote:
> But the value we want may be sitting around in a convenient register (such as
> r11). So if we force the sibcall to use %rax, then we have to generate a
> copy. Yet if we have a constraint for the set of registers allowed here, then
> we give the register allocator the opportunity to coalesce away the copies.
We do have an existing call-clobbered register class that we currently do use
for indirect sibcalls.
The problem that Kai is trying to work around is that he doesn't want to load
the value into a register, but its address. But the register allocator only
has BASE_REG_CLASS and INDEX_REG_CLASS, and has no possibility to force the
address components into registers that are call clobbered.
My thinking is that, with few exceptions, this doesn't help anything. If we
have to load the full address into a register:
lea ofs(base, index, scale), %eax
...
call *0(%eax)
we might as well include the memory load
mov ofs(base, index, scale), %eax
...
call *%eax
As far as I can see, the only time we can actually save an instruction is when
the address is fully symbolic:
mov foo, %eax
...
call *%eax
becomes
call *foo
r~