]> git.sesse.net Git - stockfish/commitdiff
Remove as useless micro-optimization in pawns generation (#1915)
authorprotonspring <mike@whiteley.org>
Tue, 1 Jan 2019 12:35:53 +0000 (05:35 -0700)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Tue, 1 Jan 2019 12:35:53 +0000 (13:35 +0100)
The extra condition is used as a shortcut to skip the following 3 assignments:

```C++
        Bitboard b1 = shift<UpRight>(pawnsOn7) & enemies;
        Bitboard b2 = shift<UpLeft >(pawnsOn7) & enemies;
        Bitboard b3 = shift<Up     >(pawnsOn7) & emptySquares;
```

In case of EVASION with no target on 8th rank (the common case), we end up performing the 3 statements for nothing because b1 = b2 = b3 = 0.

But this is just a small micro-optimization and the condition is quite confusing, so just remove it and prefer a readable code instead.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 78020 W: 16978 L: 16967 D: 44075
http://tests.stockfishchess.org/tests/view/5c27b4fe0ebc5902ba135bb0

No functional change.

src/movegen.cpp

index 76a27d9f4936320165c0378f2b59225038b0abbe..e7678979f42450029c78d70cb0afe0d01358139e 100644 (file)
@@ -96,7 +96,6 @@ namespace {
     // Compute our parametrized parameters at compile time, named according to
     // the point of view of white side.
     constexpr Color     Them     = (Us == WHITE ? BLACK      : WHITE);
     // Compute our parametrized parameters at compile time, named according to
     // the point of view of white side.
     constexpr Color     Them     = (Us == WHITE ? BLACK      : WHITE);
-    constexpr Bitboard  TRank8BB = (Us == WHITE ? Rank8BB    : Rank1BB);
     constexpr Bitboard  TRank7BB = (Us == WHITE ? Rank7BB    : Rank2BB);
     constexpr Bitboard  TRank3BB = (Us == WHITE ? Rank3BB    : Rank6BB);
     constexpr Direction Up       = (Us == WHITE ? NORTH      : SOUTH);
     constexpr Bitboard  TRank7BB = (Us == WHITE ? Rank7BB    : Rank2BB);
     constexpr Bitboard  TRank3BB = (Us == WHITE ? Rank3BB    : Rank6BB);
     constexpr Direction Up       = (Us == WHITE ? NORTH      : SOUTH);
@@ -161,7 +160,7 @@ namespace {
     }
 
     // Promotions and underpromotions
     }
 
     // Promotions and underpromotions
-    if (pawnsOn7 && (Type != EVASIONS || (target & TRank8BB)))
+    if (pawnsOn7)
     {
         if (Type == CAPTURES)
             emptySquares = ~pos.pieces();
     {
         if (Type == CAPTURES)
             emptySquares = ~pos.pieces();