function calls
Jim Giles
jlg at lambda.UUCP
Fri Mar 23 07:23:26 AEST 1990
>From article <29585 at amdcad.AMD.COM>, by tim at nucleus.amd.com (Tim Olson):
> [...]
> The compiler that I used to collect the stats will keep all live
> scalars in the register file, [...] [^^^]
I don't believe a word of it. The word I don't believe is 'all'.
_ANY_ scalar that is visible in the local scope and has a value
which might still be used by the program at some future point is 'live'.
(The same obviously applies to non-scalar values.) That is the definition
of 'live'. What you really mean is that the compiler breaks code into
'basic blocks' and keeps all active values from _that_ block in registers.
The use of 'basic blocks' and the lack of global dataflow analysis is
confusing you into thinking that only a few values are 'live' at a given
point. Also, it is considerable mistake not to regard non-scalar values
as important.
The bottom line is that registers are an important resource in any machine.
They are often more that 10 times faster than memory to reference. Your
analysis indicates that your code (whether the compiler is responsible
or not) is using this resource to only a small fraction of its potential.
But instead of complaining, you are acting like it is a desireable way
for the code to behave.
> | My experience (I don't have statistics) with both Fortran and C is that
> ^^^^^^^^^^^^^^^^^^^^^^^
> Oh.
Ok, now I have statistics. I just did a quick survey of some expertly
crafted C code that I have source code to (it's actually part of the
X11 window package). This is only a small program (it's xlock for those
interested in checking). Still, there are over 50 scalar variables
declared global to the utility - these are _ALWAYS_ 'live'. Further,
this code includes a lot of window related declarations (which also
contain a bunch of _ALWAYS_ 'live' global declarations). This is
admittedly a small sample and it disregards local variables and non-scalars.
Still, since most of the program consists of small procedures which
manipulate these global variables, I suspect it would be a smaller, faster
code if the values always occupied registers. xlock probably doesn't
need to be faster, but if speed were important, register usage would
be too.
J. Giles
More information about the Comp.lang.c
mailing list