Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!amdcad!sun!decwrl!hplabs!ucbvax!unisoft!l nptoad!gnu From: gnu@l nptoad.uucp (John Gilmore) Newsgroups: comp.lang.c Subject: Re: register unions Keywords: registers, unions Message-ID: <4098@loptoad.uucp> Date: 21 Feb 88 11:47:58 GMT References: <1229@eneevax.UUCP> Organization: Nebula Consultants in San Francisco Lines: 30 noise@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@prep to encourage others to do so. -- {pyramid,ptsfa,amdahl,sun,ihnp4}!l nptoad!gnu gnu@toad.com "Watch me change my world..." -- Liquid Theat