libgcc: strange optimization
Andrew Haley
aph@redhat.com
Thu Aug 4 14:46:00 GMT 2011
On 08/04/2011 12:19 PM, Richard Guenther wrote:
> On Thu, Aug 4, 2011 at 1:10 PM, Andrew Haley <aph@redhat.com> wrote:
>> On 08/04/2011 10:52 AM, Richard Guenther wrote:
>>> On Thu, Aug 4, 2011 at 11:50 AM, Andrew Haley <aph@redhat.com> wrote:
>>>> On 08/04/2011 01:19 AM, Hans-Peter Nilsson wrote:
>>>>
>>>>> To make sure, it'd be nice if someone could perhaps grep an
>>>>> entire GNU/Linux-or-other distribution including the kernel for
>>>>> uses of asm-declared *local* registers that don't directly feed
>>>>> into asms and not being the stack-pointer? Or can we get away
>>>>> with just saying that local asm registers haven't had any other
>>>>> documented meaning for the last seven years?
>>>>
>>>> It's the sort of thing that gets done in threaded interpreters,
>>>> where you really need to keep a few pointers in registers and
>>>> the interpreter itself is a very long function. gcc has always
>>>> done a dreadful job of register allocation in such cases.
>>>
>>> Sure, but what I have seen people use global register variables
>>> for this (which means they get taken away from the register allocator).
>>
>> Not always though, and the x86 has so few registers that using a
>> global register variable is very problematic. I suppose you could
>> compile the threaded interpreter in a file of its own, but I'm not
>> sure that has quite the same semantics as local register variables.
>>
>> The problem is that people who care about this stuff very much don't
>> always read gcc@gcc.gnu.org so won't be heard. But in their own world
>> (LISP, Forth) nice features like register variables and labels as
>> values have led to gcc being the preferred compiler for this kind of
>> work.
>
> Well, the uses won't break with the idea - they would simply work
> like if they were not using local register variables.
I don't understand this remark. Surely if they work like they were
not using local register variables, you'll get dreadful register
allocation. But this is a big reason to use gcc. Efficient code
really does matter to people writing this kind of thing.
Andrew.
More information about the Gcc
mailing list