May too many register variables hurt? (was Re: Novice question.)

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Nov 28 09:02:30 AEST 1990


In article <976 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
> In short, I tried to warn the reader that everything which exceeds two
> register declarations in the outmost block of a function *could* result in
> code that performed worse than with fewer declarations (hence the subject).

Sure. And it *could* also result in much better code. What most of us
are saying is that in practice extra register declarations help much
more than they hurt. In typical programs, some variables are used quite
a lot, and they should be declared register. Some variables are rarely
used, and they shouldn't be declared register. It's better to err on the
side of extra register declarations than to pessimize your code in the
common case. Past that, who cares? The language doesn't provide better
mechanisms for asserting variable use, so you won't be able to outguess
the compiler in very many cases.

---Dan



More information about the Comp.lang.c mailing list