Author: Daniel Clausen
Date: 08:49:20 06/05/01
Go up one level in this thread
Hi On June 05, 2001 at 11:28:27, Vincent Diepeveen wrote: > >In this piece of crap code i see everywhere: > > if (side == WHITE) > tsq = B->WhiteKnights; > else > tsq = B->BlackKnights; > >Note you can eliminate these branches, which speeds code up bigtime. > >In a test to generate for white a few million of times a list of moves >the branches will be correctly predicted, but normally spoken you get >a big misprediction there as then you generate for white and next >move for black, that hurts :) First, note that the same if (side == WHITE) appears in the same function several times so if side is WHITE on the first check, it's likely that it stays WHITE until the end of the function. Second, there are processors which use more than 1 bit for branch prediction. (I think the Sparc-architecture is one of them, but I'm not sure) So recognizing simple patterns like 101010 or thelike would not be a problem for such architectures either. Note that I don't imply with this posting that I actually like the code you [Diep] quoted. But it's also not as simple as replacing "B->WhitePawns" and "B->BlackPawns" etc with "B->Piece[PieceType][sideToMove]". I guess that it's more likely for bitboard programs that different pieces need special treatment. This is because information tends to be 'scattered' in different bitboards for different pieces. Regards, Sargon
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.