1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Micro-optimze extension()

Explicitly write the conditions for pawn to 7th
and passed pawn instead of wrapping in redundant
helpers.

Also retire the now unused move_is_pawn_push_to_7th()
and the never used move_was_passed_pawn_push() and
move_is_deep_pawn_push()

Function extension() is so time critical that this
simple patch speeds up the pgo compile of 0.5% and
it is also more clear what actually happens there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-08-24 17:41:24 +01:00
parent 2078878376
commit e217407450
2 changed files with 3 additions and 26 deletions

View file

@ -236,10 +236,7 @@ public:
bool move_is_check(Move m) const; bool move_is_check(Move m) const;
bool move_is_check(Move m, Bitboard dcCandidates) const; bool move_is_check(Move m, Bitboard dcCandidates) const;
bool move_is_capture(Move m) const; bool move_is_capture(Move m) const;
bool move_is_deep_pawn_push(Move m) const;
bool move_is_pawn_push_to_7th(Move m) const;
bool move_is_passed_pawn_push(Move m) const; bool move_is_passed_pawn_push(Move m) const;
bool move_was_passed_pawn_push(Move m) const;
bool move_attacks_square(Move m, Square s) const; bool move_attacks_square(Move m, Square s) const;
// Information about pawns // Information about pawns
@ -653,20 +650,6 @@ inline Phase Position::game_phase() const {
return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit)); return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit));
} }
inline bool Position::move_is_deep_pawn_push(Move m) const {
Color c = side_to_move();
return piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
&& relative_rank(c, move_to(m)) > RANK_4;
}
inline bool Position::move_is_pawn_push_to_7th(Move m) const {
Color c = side_to_move();
return piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
&& relative_rank(c, move_to(m)) == RANK_7;
}
inline bool Position::move_is_passed_pawn_push(Move m) const { inline bool Position::move_is_passed_pawn_push(Move m) const {
Color c = side_to_move(); Color c = side_to_move();
@ -674,13 +657,6 @@ inline bool Position::move_is_passed_pawn_push(Move m) const {
&& pawn_is_passed(c, move_to(m)); && pawn_is_passed(c, move_to(m));
} }
inline bool Position::move_was_passed_pawn_push(Move m) const {
Color c = opposite_color(side_to_move());
return piece_on(move_to(m)) == piece_of_color_and_type(c, PAWN)
&& pawn_is_passed(c, move_to(m));
}
inline int Position::rule_50_counter() const { inline int Position::rule_50_counter() const {
return st->rule50; return st->rule50;

View file

@ -2267,12 +2267,13 @@ namespace {
if (pos.type_of_piece_on(move_from(m)) == PAWN) if (pos.type_of_piece_on(move_from(m)) == PAWN)
{ {
if (pos.move_is_pawn_push_to_7th(m)) Color c = pos.side_to_move();
if (relative_rank(c, move_to(m)) == RANK_7)
{ {
result += PawnPushTo7thExtension[pvNode]; result += PawnPushTo7thExtension[pvNode];
*dangerous = true; *dangerous = true;
} }
if (pos.move_is_passed_pawn_push(m)) if (pos.pawn_is_passed(c, move_to(m)))
{ {
result += PassedPawnExtension[pvNode]; result += PassedPawnExtension[pvNode];
*dangerous = true; *dangerous = true;