Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/3/84; site enmasse.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!enmasse!mhs From: mhs@enmasse.UUCP (Mike Schloss) Newsgroups: net.lang.c Subject: Re: Re: Re: register variables Message-ID: <421@enmasse.UUCP> Date: Thu, 27-Jun-85 16:34:15 EDT Article-I.D.: enmasse.421 Posted: Thu Jun 27 16:34:15 1985 Date-Received: Sat, 29-Jun-85 00:25:36 EDT References: <472@crystal.UUCP> <365@umcp-cs.UUCP> <38@ucbcad.UUCP> Distribution: net Organization: Enmasse Computer Corp., Acton, Mass. Lines: 19 > Speaking of register variables -- does anybody know what various C > compilers do when you don't declare variables as register, but there > are spare registers to use? From what I hear, neither ccom nor c2 are > smart enough to put local variables in registers when they are > available. It seems that it would be simple to just take the first few, > or even the most heavily used local variables that don't ever get &'d > and make them register... > > Wayne Easier said than done. For example, what do you mean by most heavily used? Do you mean occurs most often in the code or encountered more often during execution. Assume two variables, one with 16 references in the first half of the routine and none in the second half, another variable with only one reference in the second half, in a loop, where the program spend 98% of its time. Get the picture? Also the is some cost to using registers, the overhead of storing and restoring them. A compiler does not know about execution paths so it can not deal with this properly. Better left to the programmer who shoud know better about variable usage and possible input data.