Author: Eugene Nalimov
Date: 21:16:44 09/05/03
Go up one level in this thread
On September 05, 2003 at 17:44:50, Dieter Buerssner wrote: >On September 05, 2003 at 17:08:43, Robert Hyatt wrote: > >>On September 05, 2003 at 16:17:48, Uri Blass wrote: >> >>>I want to have some rule when it is a good idea to use local varaibles. >>> >>>I believe that it is clear that when instead of changing the hash key zob[hply] >>>many times in my makemove it is better to start using local varaible and start >>>my makemove with >>> __int64 zob=zobkey[hply]; >>>and finish it with when hply was already increased by 1 with >>>zobkey[hply]=zob; >>> >>>My question is how many times using the same expression zobkey[hply] >>>justify using local varaible >> >>I don't see any benefit to doing what you are doing. IE >>zobkey[hply+1]=zobkey[hply]; will make the copy. The only thing you save >>is the indexing operation needed to access zobkey[hply+1] as you modify it. >>But a good compiler will probably be able to optimize that into a register >>anyway if you make sure that you copy and update it as quickly as possible >>before doing anything else... > >It is much more complicated. C Compilers in general can do better otpimizations >with local vars, than with global vars. Say some function has also some pointer >argument, that you modify (or some global pointer var is used). Often in that >case, it cannot leave a global var in register. Unless it can prove, that the >stuff your are modifying through the pointer will never alias the global var. >Current compilers will not be able to do it. With a local variable, of which >never the adress was taken, it is much easier. > >If you want Fortran, you know, where you'll find it :-) > >C99 has dealt with this problem somewhat (by the new restrict keyword). > >Regards, >Dieter Visual C (starting from 7.0) can compile whole program (link-time code generation, /GL switch). Then compiler knows that global variable is not address-taken, so it cannot alias indirect memory store. Thanks, Eugene
This page took 0.01 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.