From 1a168201bd8424da4cea384ee4c03973b2ccf0ca Mon Sep 17 00:00:00 2001 From: Giacomo Lorenzetti Date: Sun, 22 May 2022 12:47:30 +0200 Subject: [PATCH] Small speedup in futility_move_count The speedup is around 0.25% using gcc 11.3.1 (bmi2, nnue bench, depth 16 and 23) while it is neutral using clang (same conditions). According to `perf` that integer division was one of the most time-consuming instructions in search (gcc disassembly). Passed STC: https://tests.stockfishchess.org/tests/view/628a17fe24a074e5cd59b3aa LLR: 2.94 (-2.94,2.94) <0.00,2.50> Total: 22232 W: 5992 L: 5751 D: 10489 Ptnml(0-2): 88, 2235, 6218, 2498, 77 yellow LTC: https://tests.stockfishchess.org/tests/view/628a35d7ccae0450e35106f7 LLR: -2.95 (-2.94,2.94) <0.50,3.00> Total: 320168 W: 85853 L: 85326 D: 148989 Ptnml(0-2): 185, 29698, 99821, 30165, 215 This patch also suggests that UHO STC is sensible to small speedups (< 0.50%). closes https://github.com/official-stockfish/Stockfish/pull/4032 No functional change --- src/search.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index ff7b996b..0a4b1a18 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -75,7 +75,8 @@ namespace { } constexpr int futility_move_count(bool improving, Depth depth) { - return (3 + depth * depth) / (2 - improving); + return improving ? (3 + depth * depth) + : (3 + depth * depth) / 2; } // History and stats update bonus, based on depth