]> git.sesse.net Git - stockfish/commitdiff
Fix a couple of Intel compiler warnings
authorMarco Costalba <mcostalba@gmail.com>
Wed, 23 Sep 2009 13:06:55 +0000 (15:06 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 23 Sep 2009 16:01:59 +0000 (17:01 +0100)
And avoid calculating emptySquares for pawns captures
case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movegen.cpp

index 738b2acc6f1494e43ce651b7bc50de9b2926bfe0..edb36feabd796f83b2c0c9e2fa6cca25d7c69f6a 100644 (file)
@@ -576,7 +576,6 @@ namespace {
     Bitboard b1, b2, dcPawns1, dcPawns2;
     Square to;
     Bitboard pawns = (Type == EVASION ? pos.pieces(PAWN, Us) & ~dcp : pos.pieces(PAWN, Us));
     Bitboard b1, b2, dcPawns1, dcPawns2;
     Square to;
     Bitboard pawns = (Type == EVASION ? pos.pieces(PAWN, Us) & ~dcp : pos.pieces(PAWN, Us));
-    Bitboard emptySquares = pos.empty_squares();
     bool possiblePromotion = pawns & TRank7BB;
 
     if (Type == CAPTURE)
     bool possiblePromotion = pawns & TRank7BB;
 
     if (Type == CAPTURE)
@@ -621,7 +620,7 @@ namespace {
 
         // Underpromotion pawn pushes. Also queen promotions for evasions and captures.
         b1 = move_pawns<Us, DELTA_N>(pp) & TRank8BB;
 
         // Underpromotion pawn pushes. Also queen promotions for evasions and captures.
         b1 = move_pawns<Us, DELTA_N>(pp) & TRank8BB;
-        b1 &= (Type == EVASION ? blockSquares : emptySquares);
+        b1 &= (Type == EVASION ? blockSquares : pos.empty_squares());
 
         while (b1)
         {
 
         while (b1)
         {
@@ -638,47 +637,45 @@ namespace {
         }
     }
 
         }
     }
 
-    if (Type == CAPTURE)
+    if (Type != CAPTURE)
     {
     {
-        // En passant captures
-        if (pos.ep_square() != SQ_NONE)
+        Bitboard emptySquares = pos.empty_squares();
+        dcPawns1 = dcPawns2 = EmptyBoardBB;
+        if (Type == CHECK && (pawns & dcp))
         {
         {
-            assert(Us != WHITE || square_rank(pos.ep_square()) == RANK_6);
-            assert(Us != BLACK || square_rank(pos.ep_square()) == RANK_3);
-
-            Bitboard b1 = pawns & pos.attacks_from<PAWN>(pos.ep_square(), Them);
-            assert(b1 != EmptyBoardBB);
-
-            while (b1)
-            {
-                to = pop_1st_bit(&b1);
-                (*mlist++).move = make_ep_move(to, pos.ep_square());
-            }
+            // Pawn moves which gives discovered check. This is possible only if the
+            // pawn is not on the same file as the enemy king, because we don't
+            // generate captures.
+            dcPawns1 = move_pawns<Us, DELTA_N>(pawns & dcp & ~file_bb(ksq)) & emptySquares & ~TRank8BB;
+            dcPawns2 = move_pawns<Us, DELTA_N>(dcPawns1 & TRank3BB) & emptySquares;
         }
         }
-        return mlist;
-    }
 
 
-    dcPawns1 = dcPawns2 = EmptyBoardBB;
-    if (Type == CHECK && (pawns & dcp))
-    {
-        // Pawn moves which gives discovered check. This is possible only if the
-        // pawn is not on the same file as the enemy king, because we don't
-        // generate captures.
-        dcPawns1 = move_pawns<Us, DELTA_N>(pawns & dcp & ~file_bb(ksq)) & emptySquares & ~TRank8BB;
-        dcPawns2 = move_pawns<Us, DELTA_N>(dcPawns1 & TRank3BB) & emptySquares;
+        // Single pawn pushes
+        b1 = move_pawns<Us, DELTA_N>(pawns) & emptySquares & ~TRank8BB;
+        b2 = (Type == CHECK ? (b1 & pos.attacks_from<PAWN>(ksq, Them)) | dcPawns1 :
+              (Type == EVASION ? b1 & blockSquares : b1));
+        SERIALIZE_MOVES_D(b2, -TDELTA_N);
+
+        // Double pawn pushes
+        b1 = move_pawns<Us, DELTA_N>(b1 & TRank3BB) & emptySquares;
+        b2 = (Type == CHECK ? (b1 & pos.attacks_from<PAWN>(ksq, Them)) | dcPawns2 :
+              (Type == EVASION ? b1 & blockSquares : b1));
+        SERIALIZE_MOVES_D(b2, -TDELTA_N -TDELTA_N);
     }
     }
+    else if (pos.ep_square() != SQ_NONE) // En passant captures
+    {
+        assert(Us != WHITE || square_rank(pos.ep_square()) == RANK_6);
+        assert(Us != BLACK || square_rank(pos.ep_square()) == RANK_3);
+
+        b1 = pawns & pos.attacks_from<PAWN>(pos.ep_square(), Them);
+        assert(b1 != EmptyBoardBB);
 
 
-    // Single pawn pushes
-    b1 = move_pawns<Us, DELTA_N>(pawns) & emptySquares & ~TRank8BB;
-    b2 = (Type == CHECK ? (b1 & pos.attacks_from<PAWN>(ksq, Them)) | dcPawns1 :
-         (Type == EVASION ? b1 & blockSquares : b1));
-    SERIALIZE_MOVES_D(b2, -TDELTA_N);
-
-    // Double pawn pushes
-    b1 = move_pawns<Us, DELTA_N>(b1 & TRank3BB) & emptySquares;
-    b2 = (Type == CHECK ? (b1 & pos.attacks_from<PAWN>(ksq, Them)) | dcPawns2 :
-         (Type == EVASION ? b1 & blockSquares : b1));
-    SERIALIZE_MOVES_D(b2, -TDELTA_N -TDELTA_N);
+        while (b1)
+        {
+            to = pop_1st_bit(&b1);
+            (*mlist++).move = make_ep_move(to, pos.ep_square());
+        }
+    }
     return mlist;
   }
 
     return mlist;
   }
 
@@ -706,19 +703,19 @@ namespace {
     // Direct non-capture checks
     b = target & ~dc;
     Bitboard checkSqs = pos.attacks_from<Piece>(ksq) & pos.empty_squares();
     // Direct non-capture checks
     b = target & ~dc;
     Bitboard checkSqs = pos.attacks_from<Piece>(ksq) & pos.empty_squares();
-    if (Piece == KING || !checkSqs)
-        return mlist;
-
-    while (b)
+    if (Piece != KING && checkSqs)
     {
     {
-        Square from = pop_1st_bit(&b);
-        if (   (Piece == QUEEN  && !(QueenPseudoAttacks[from]  & checkSqs))
-            || (Piece == ROOK   && !(RookPseudoAttacks[from]   & checkSqs))
-            || (Piece == BISHOP && !(BishopPseudoAttacks[from] & checkSqs)))
-            continue;
-
-        Bitboard bb = pos.attacks_from<Piece>(from) & checkSqs;
-        SERIALIZE_MOVES(bb);
+        while (b)
+        {
+            Square from = pop_1st_bit(&b);
+            if (   (Piece == QUEEN  && !(QueenPseudoAttacks[from]  & checkSqs))
+                || (Piece == ROOK   && !(RookPseudoAttacks[from]   & checkSqs))
+                || (Piece == BISHOP && !(BishopPseudoAttacks[from] & checkSqs)))
+                continue;
+
+            Bitboard bb = pos.attacks_from<Piece>(from) & checkSqs;
+            SERIALIZE_MOVES(bb);
+        }
     }
     return mlist;
   }
     }
     return mlist;
   }