From: Marco Costalba Date: Fri, 27 Aug 2010 10:15:07 +0000 (+0200) Subject: Split branches in generate_piece_moves() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=d9dc9dbd65263f8644afcc1fc632e9201ad20c70;hp=2a2353aac65d6f7263081dc373c768c8717602db Split branches in generate_piece_moves() Instead of one comparison in while() condition use two, the first to check if the piece is exsistant and the second to loop across pieces of that type. This should help branch prediction in cases we have only one piece of the same type, for instance for queens, the first branch is always true and the second is almost always false. Increased speed of 0.3-0.5 % on Gcc pgo compiles. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/movegen.cpp b/src/movegen.cpp index 0598249d..ea3255cc 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -429,10 +429,13 @@ namespace { Square from; const Square* ptr = pos.piece_list_begin(us, Piece); - while ((from = *ptr++) != SQ_NONE) + if (*ptr != SQ_NONE) { - b = pos.attacks_from(from) & target; - SERIALIZE_MOVES(b); + do { + from = *ptr; + b = pos.attacks_from(from) & target; + SERIALIZE_MOVES(b); + } while (*++ptr != SQ_NONE); } return mlist; }