]> git.sesse.net Git - stockfish/commitdiff
Small speedup in futility_move_count
authorGiacomo Lorenzetti <g.lorenz9@protonmail.com>
Sun, 22 May 2022 10:47:30 +0000 (12:47 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 29 May 2022 16:54:19 +0000 (18:54 +0200)
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

index ff7b996be5710e05ef0f0a46605e8d6f00fc8ba0..0a4b1a18d672e991d5a95b3e1e02304eecac6b3e 100644 (file)
@@ -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