Re: TomsFastMath speeds

From: Colin Andrew Percival (cperciva_at_sfu.ca)
Date: 07/25/05


Date: Mon, 25 Jul 2005 19:22:37 +0000 (UTC)

Grumble <devnull@kma.eu.org> wrote:
> Colin Percival wrote:
>> [gcc] will decide that 16 or more variables are all "common
>> subexpressions" and that they should all be stored in registers, then
>> realize that it doesn't have enough registers and spill them all onto the
>> stack. Instead of simply storing them in memory where they're supposed
>> to go, which would be faster than allocating space for them on the
>> stack.)
>
> I don't understand... The stack IS in memory. Pushing a value on the
> stack means, in fact, writing to memory.
>
> What do you mean by "simply storing them in memory" ?

I should have said "simply writing those values into the locations where
those variables are supposed to be stored". For example, I access
doubles stored at X[0], X[1], X[2]... X[15], and in the middle of the
code I have the line
        X[8] = X[0] - X[8]
After it computes X[0] - X[8], gcc decides that it shouldn't store that
value into X[8] -- instead, it stores it onto the stack, uses it from
there for a while, and then at the end it loads the value from the stack
and stores it into X[8].

The problem is that the gcse stage is done before the register-allocation
stage, and gcc doesn't have any feedback mechanism so it can't say "hey,
stop looking for common subexpressions, I don't have space to store all
of them". (Yes, they know about this problem.)

Colin Percival



Relevant Pages

  • Re: pass variable argument list on somehow?
    ... >apparently when arguments are passed they're passed both on the stack ... >Typically the calling routine passes parameters in registers. ... any parameters that do not fit in registers in memory that immediately ... Other ABIs for the PowerPC leave the argument dump areas separate, ...
    (comp.lang.c)
  • Re: About stack size
    ... > I meant that stack area should be contiguous. ... Memory Manager is in charge of allocating space ... be used to access memory while other registers ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Zero operand CPUs
    ... the stack in on-chip RAM, ... the oldest part of it to main memory, ... based on how many cells are cached in registers. ... do to simplify the design to reduce cost and power use and increase ...
    (comp.arch.embedded)
  • Re: stack and a heap
    ... >> They are both memory which is used to store objects. ... The stack is also used to ... > can end up on the heap as part of other objects. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TomsFastMath speeds
    ... > realize that it doesn't have enough registers and spill them all onto the ... Instead of simply storing them in memory where they're supposed ... > stack.) ... The stack IS in memory. ...
    (sci.crypt)