Author: Gerd Isenberg
Date: 00:31:29 12/06/05
Go up one level in this thread
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 a) mixture of a and b // assuming color ::= {0,1} := {white, black} shiftCountWhite = shiftCount & (color-1); shiftCountBlack = shiftCount & -color; // shiftCountWhite ^ shiftCount x <<= shiftCountWhite; x >>= shiftCountBlack; d) conditional generalized shift. if (color) x >>= shiftCount; else x <<= shiftCount; If the routine is inlined and color is a compile time constant (due to unrolling color loops) the compiler will optimize the none taken branch away - otherwise how likely is a misprediction? Gerd
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.