Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Mixing 0x88 and bitboards

Author: Robert Hyatt

Date: 14:19:20 06/25/02

Go up one level in this thread


On June 25, 2002 at 17:09:42, Dieter Buerssner wrote:

>On June 25, 2002 at 16:35:26, Gian-Carlo Pascutto wrote:
>
>>if (board[E6] == wpawn)
>>
>>1 load
>>1 compare
>>
>>if (WhitePawns & Mask[e6])
>>
>>2 64-bit loads
>>1 64-bit and
>>1 64-bit compare
>
>Hidden in some macros one could write
>
>  if ((WhitePawns.low32 & Mask[e6].low32)
>      | (WhitePawns.high32 & Mask[e6].high32))
>
>4 32 bit loads,
>2 32 bit ands
>1 32 bit or and branch based on the flags.
>
>An intelligent compiler could produce better code with something like
>
>if (WhitePawns & (1ULL << E6))
>
>1 32-bit load,
>1 32-bit and, branch based on the flags.
>
>Of course, this optimization cannot work anymore, when E6 is "sq".


Actually it can.  while waiting on the load (several clocks) you could
do the following, which we did in Cray Blitz all over the place:

(pseudo-code rather than Cray assembly):
load  r2, pawns
clear r1
add   r1,1
shiftl r1,sq
... wait for load data to arrive
AND r1,r2

The idea of getting a "1" in a register then shifting it to the right
mask bit is very common.  And rather than loading a single-bit mask from
memory, we did as I gave above.  Those instructions are buried in the shadow
of that long memory access (or even a L2 cache access) so that they don't
matter and don't cost a thing.



>
>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.