From c41c9bb9733be48b232afd042c9331dde9000e03 Mon Sep 17 00:00:00 2001 From: anematode Date: Thu, 2 Apr 2026 20:26:30 +0200 Subject: [PATCH] Add -fno-ipa-cp-clone on GCC Passed non-regression STC at tests.stockfishchess.org/tests/view/69c9b8c3a54395a761335044 (set to gainer bounds, *mea culpa*) There's a major performance penalty when compiling the fish with GCC 16. @Torom 's measurements (similar to mine, but more precise): ``` GCC 15 (master) vs. 16 (master) sf_base = 2549174 +/- 2984 (95%) sf_test = 2435456 +/- 2239 (95%) diff = -113718 +/- 3599 (95%) speedup = -4.46100% +/- 0.141% (95%) GCC 15 (master) vs. 16 (patch) sf_base = 2544107 +/- 3091 (95%) sf_test = 2568837 +/- 3164 (95%) diff = 24729 +/- 4359 (95%) speedup = 0.97204% +/- 0.171% (95%) ``` Based on looking at the disassembly + profiling data of the builds, the root cause appears to be overly aggressive code duplication from constant propagation of various functions especially in `search.cpp`. The worst offender is `Worker::search`, which I think is being cloned and optimized based on the value of `cutNode`. `perf stat` indicates that the instruction cache miss rate goes up by ~50% on the GCC 16 build. closes https://github.com/official-stockfish/Stockfish/pull/6691 No functional change --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index c4ea80207..48847bc78 100644 --- a/src/Makefile +++ b/src/Makefile @@ -451,7 +451,7 @@ endif ifeq ($(COMP),gcc) comp=gcc CXX=g++ - CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations + CXXFLAGS += -pedantic -Wextra -Wshadow -Wmissing-declarations -fno-ipa-cp-clone ifeq ($(arch),$(filter $(arch),armv7 armv8 riscv64)) ifeq ($(OS),Android)