register variables

Alan T. Bowler [SDG] atbowler at watmath.UUCP
Wed Jul 17 11:09:38 AEST 1985


The semantic meaning of a "register" declaration is NOT that the compiler
must place the variable in a register.  Instead if you stop to think
it is really a declaration that this variable is never affected as a
side effect of an indirect store (* or []), an so a copy of the variable
in a register can still be believed.  The "register" declaration
should really only be interpreted in this sense, even though some compilers
decide to always keep the first few such variables in registers.  Compilers
that do such are not in violation of this interpretation, but are taking
an unneccessarily narrow interpretation, and as a result some times
produce worse code since they lose the use of extra registers when
they would be most useful.  "register" is supposed to be an optimizing
HINT, not suboptimal code requirement.



More information about the Comp.lang.c mailing list