Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: ASM/Optimization

Author: Lance Perkins

Date: 22:32:58 12/05/05

Go up one level in this thread


int PawnForwardRotate[] = {8,64-8};
unsigned __int64 PawnForwardMask[] = {0xffffffffffffff00, 0x00ffffffffffffff};

_rotl64 (bbPawns, PawnForwardRotate[color]) & PawnForwardMask[color];

// pre-cond:
//    Rax = pawn bb
//    Rdx = color

mov ecx, DWORD PTR PawnForwardRotate[Rdx*4]
rol rax, cl
and rax, QWORD PTR PawnForwardMask[Rdx*8]


On December 05, 2005 at 23:24:52, Zappa wrote:

>I am getting really, really tired of coding all my evaluation twice (once for
>white and once for black).  However, one of the things that is keeping me from
>switching to a for(i < 2) loop is that I can't do a shift!
>
>For example, if I have some pattern based on (pawns << 8) for white, than that
>is (pawns >> 8) for black, and you can't do a negative shift in IA32.
>
>My ideas:
>
>Eugene will happily point out that on the Itanium doing two shifts and selecting
>the correct value is 1 (2?) bundles.
>
>Otherwise on AMD64 I could do
>
>a) two shifts & cmov.  I think 5 instructions (as compared to 1, and I have a
>LOT of shifts).
>
>b) << followed by >>.  1 extra instruction but I have twice as many loads for
>constants.
>
>c) rotate (X | 64-x) (but then I have the possibility of things ending up
>rotating around).
>
>d) your name here . . . :)
>
>I am not that concerned about latency because there would usually be alot of
>stuff around that could be rescheduled, but if I have to do 5 instructions for
>every shift my code size will triple.
>
>anthony



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.