Author: Dieter Buerssner
Date: 12:55:25 12/03/04
Go up one level in this thread
On December 03, 2004 at 13:36:15, Reinhard Scharnagl wrote: >I am convinced that a good compiler always will translate a "x % (2^n)" term >into "x & (2^n-1)", so it would be hard to program the difference. (Check it >with a disassembler). I doubt very much, that this optimization is possible in a typical chess engine (where the number of entries is given at run time, and even when forced to a power of 2, it will be hard for the compiler to figure this out). When the number of entries is a compile time constant, the compiler will have no problem to figure it out, of course. It won't make a difference in either case on typical PC hardware, where the memory accesses later are much slower, than the index calculation, even when done with modulo. Full 64 bit modulo might be a bit slower, because typically the compiler must use some support function for it, and cannot use the div instruction (because of "division by zero"). For 2^32 entries or less, using modulo on 32 bits of a 64 bit hashkey will work without any disadvantages, and will produce efficient code on x86. Regards, Dieter
This page took 0 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.