]> git.sesse.net Git - stockfish/commitdiff
Fix a compiler bug on Clang 15+ with AVX-512
authorMinetaS <skdty87@gmail.com>
Tue, 17 Oct 2023 19:03:39 +0000 (04:03 +0900)
committerDisservin <disservin.social@gmail.com>
Mon, 23 Oct 2023 18:39:48 +0000 (20:39 +0200)
fixes https://github.com/official-stockfish/Stockfish/issues/4450
closes https://github.com/official-stockfish/Stockfish/pull/4830

No functional change.

src/syzygy/tbprobe.cpp

index c8e60ab6c02a8e87474a4244bac02ef6ee36e2e4..31597f835a8264b9e9c1dda890a31b3f98c8199c 100644 (file)
@@ -690,6 +690,17 @@ int map_score(TBTable<DTZ>* entry, File f, int value, WDLScore wdl) {
     return value + 1;
 }
 
+// A temporary fix for the compiler bug with AVX-512. (#4450)
+#ifdef USE_AVX512
+    #if defined(__clang__) && defined(__clang_major__) && __clang_major__ >= 15
+        #define CLANG_AVX512_BUG_FIX __attribute__((optnone))
+    #endif
+#endif
+
+#ifndef CLANG_AVX512_BUG_FIX
+    #define CLANG_AVX512_BUG_FIX
+#endif
+
 // Compute a unique index out of a position and use it to probe the TB file. To
 // encode k pieces of the same type and color, first sort the pieces by square in
 // ascending order s1 <= s2 <= ... <= sk then compute the unique index as:
@@ -697,7 +708,8 @@ int map_score(TBTable<DTZ>* entry, File f, int value, WDLScore wdl) {
 //      idx = Binomial[1][s1] + Binomial[2][s2] + ... + Binomial[k][sk]
 //
 template<typename T, typename Ret = typename T::Ret>
-Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* result) {
+CLANG_AVX512_BUG_FIX Ret
+do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* result) {
 
     Square     squares[TBPIECES];
     Piece      pieces[TBPIECES];