|register variables in C. firstname.lastname@example.org (1992-04-22)|
|register variables in C. email@example.com (1992-04-22)|
|Re: register variables in C. firstname.lastname@example.org (1992-04-23)|
|Re: register variables in C. email@example.com (1992-04-23)|
|Re: register variables in C. dave.howell@ColumbiaSC.NCR.COM (Dave Howell) (1992-04-24)|
|Re: register variables in C. firstname.lastname@example.org (1992-04-29)|
|Re: register variables in C. email@example.com (1992-04-30)|
|Re: register variables in C. Brian.Scearce@Eng.Sun.COM (1992-04-30)|
|Re: register variables in C. firstname.lastname@example.org (1992-05-01)|
|Re: register variables in C. metaware!miker@uunet.UU.NET (1992-05-01)|
|[7 later articles]|
|From:||email@example.com (David DiGiacomo)|
|Keywords:||C, registers, optimize|
|Organization:||MIPS Computer Systems, Inc.|
|Date:||Thu, 23 Apr 1992 01:57:14 GMT|
In article 92-04-108 firstname.lastname@example.org writes:
>In general, can a good optimizing C compiler do a better job
>of assigning registers to variables better than the programmer?
I don't know about the general case, but don't count on it. In the past I
did a lot of experimentation with Sun C (<= V1.0), and found that for
complicated graphics code which had more live variables than the machine
had registers, the compiler was unable to pick the right variables to put
in the registers. (MIPS cc seems somewhat better, but I don't have as
much experience with it.)
On the other hand, the register declaration mechanism in C is clumsy and
by-hand register allocation is at odds with good programming style.
>In other words, should a programmer ever use the "register" storage class?
Only if the programmer knows that the compiler will not ignore it -- most
compilers begin to ignore register declarations completely at a certain
optimization level (-O2 for Sun and MIPS; Sun C went so far as to not
notice "register int foo; bar = &foo;" at that level). Often the
performance gain from the other optimizations in effect at this level is
more significant than the loss from the compiler's imperfect register
allocation. Coincidentally this is the same level where debugging becomes
difficult, so if the code is still being debugged, but reasonable
performance is desired, register declarations are necessary.
Return to the
Search the comp.compilers archives again.