register unions
John Gilmore
gnu at lnptoad.uucp
Sun Feb 21 21:47:58 AEST 1988
noise at eneevax.UUCP (Johnson Noise) wrote:
> Unfortunately, all the compilers I have
> tried (including pcc) will not allocate unions in registers.
> If there aren't any problems, I would like to incorporate these
> and other concepts into my copy of gcc.
I think gcc (the GNU C Compiler) will put unions into registers. I have
seen it put a struct into a register. I couldn't get the simple examples
Johnson used to allocate a register -- the optimizer was smart enough
to notice that it was only used a few times or was constant, so why
waste a register on it!
While compiling most of Berkeley Unix with gcc I ran across two programs
that declared "register struct foo bar" and then took the address of bar!
(You cain't do that to register variables). PCC never complained because it
forgets that you called something "register" if it doesn't actually put
it in a register.
Doug Gwyn noted that you wouldn't get a variable allocated to d0 on the 68000
anyway, since it's a scratch register. Gcc is smart enough to put variables
in d0 that aren't used across a function call (or any variable, in a "leaf"
routine that makes no function calls).
It's fun having the fastest 68K C compiler be the free one, though that
can't last forever. If you notice that GCC is generating slow code though,
you could help by improving it, or at least send a note to bug-gcc at prep
to encourage others to do so.
--
{pyramid,ptsfa,amdahl,sun,ihnp4}!l nptoad!gnu gnu at toad.com
"Watch me change my world..." -- Liquid Theat
More information about the Comp.lang.c
mailing list