]> git.sesse.net Git - stockfish/commitdiff
Avoid casting to char* in prefetch()
authorMarco Costalba <mcostalba@gmail.com>
Sat, 7 Feb 2015 18:13:41 +0000 (19:13 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 7 Feb 2015 18:13:41 +0000 (19:13 +0100)
Funny enough, gcc __builtin_prefetch() expects
already a void*, instead Windows's _mm_prefetch()
requires a char*.

The patch allows to remove ugly casts from caller
sites.

No functional change.

src/misc.cpp
src/misc.h
src/position.cpp
src/search.cpp

index 1674c2a602b85f02e54c1690696ff8f2630440ce..daafd3fb650cbd009cee475402474f2786d43871 100644 (file)
@@ -176,11 +176,11 @@ void start_logger(bool b) { Logger::start(b); }
 /// which can be quite slow.
 #ifdef NO_PREFETCH
 
 /// which can be quite slow.
 #ifdef NO_PREFETCH
 
-void prefetch(char*) {}
+void prefetch(void*) {}
 
 #else
 
 
 #else
 
-void prefetch(char* addr) {
+void prefetch(void* addr) {
 
 #  if defined(__INTEL_COMPILER)
    // This hack prevents prefetches from being optimized away by
 
 #  if defined(__INTEL_COMPILER)
    // This hack prevents prefetches from being optimized away by
@@ -189,7 +189,7 @@ void prefetch(char* addr) {
 #  endif
 
 #  if defined(__INTEL_COMPILER) || defined(_MSC_VER)
 #  endif
 
 #  if defined(__INTEL_COMPILER) || defined(_MSC_VER)
-  _mm_prefetch(addr, _MM_HINT_T0);
+  _mm_prefetch((char*)addr, _MM_HINT_T0);
 #  else
   __builtin_prefetch(addr);
 #  endif
 #  else
   __builtin_prefetch(addr);
 #  endif
index 9d3c58c87d2859d16a1286155917c1816ec55f84..28bf045255ccd8b6aae115020ce285cc4fafb651 100644 (file)
@@ -28,7 +28,7 @@
 #include "types.h"
 
 const std::string engine_info(bool to_uci = false);
 #include "types.h"
 
 const std::string engine_info(bool to_uci = false);
-void prefetch(char* addr);
+void prefetch(void* addr);
 void start_logger(bool b);
 
 void dbg_hit_on(bool b);
 void start_logger(bool b);
 
 void dbg_hit_on(bool b);
index bb5a86f47f35f9b13778b79c8cbc2f655f8120c8..c02fdf625d26e646a676294fdb926be92d64b722 100644 (file)
@@ -774,7 +774,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
       // Update material hash key and prefetch access to materialTable
       k ^= Zobrist::psq[them][captured][capsq];
       st->materialKey ^= Zobrist::psq[them][captured][pieceCount[them][captured]];
       // Update material hash key and prefetch access to materialTable
       k ^= Zobrist::psq[them][captured][capsq];
       st->materialKey ^= Zobrist::psq[them][captured][pieceCount[them][captured]];
-      prefetch((char*)thisThread->materialTable[st->materialKey]);
+      prefetch(thisThread->materialTable[st->materialKey]);
 
       // Update incremental scores
       st->psq -= psq[them][captured][capsq];
 
       // Update incremental scores
       st->psq -= psq[them][captured][capsq];
@@ -841,7 +841,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
 
       // Update pawn hash key and prefetch access to pawnsTable
       st->pawnKey ^= Zobrist::psq[us][PAWN][from] ^ Zobrist::psq[us][PAWN][to];
 
       // Update pawn hash key and prefetch access to pawnsTable
       st->pawnKey ^= Zobrist::psq[us][PAWN][from] ^ Zobrist::psq[us][PAWN][to];
-      prefetch((char*)thisThread->pawnsTable[st->pawnKey]);
+      prefetch(thisThread->pawnsTable[st->pawnKey]);
 
       // Reset rule 50 draw counter
       st->rule50 = 0;
 
       // Reset rule 50 draw counter
       st->rule50 = 0;
@@ -988,7 +988,7 @@ void Position::do_null_move(StateInfo& newSt) {
   }
 
   st->key ^= Zobrist::side;
   }
 
   st->key ^= Zobrist::side;
-  prefetch((char*)TT.first_entry(st->key));
+  prefetch(TT.first_entry(st->key));
 
   ++st->rule50;
   st->pliesFromNull = 0;
 
   ++st->rule50;
   st->pliesFromNull = 0;
index 34fcc17637211029366f6868bb0bcf8d392cb971..7f733a950f73bb0904fe8abaa35fd458f8c9044a 100644 (file)
@@ -872,7 +872,7 @@ moves_loop: // When in check and at SpNode search starts from here
       }
 
       // Speculative prefetch as early as possible
       }
 
       // Speculative prefetch as early as possible
-      prefetch((char*)TT.first_entry(pos.key_after(move)));
+      prefetch(TT.first_entry(pos.key_after(move)));
 
       // Check for legality just before making the move
       if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
 
       // Check for legality just before making the move
       if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
@@ -1238,7 +1238,7 @@ moves_loop: // When in check and at SpNode search starts from here
           continue;
 
       // Speculative prefetch as early as possible
           continue;
 
       // Speculative prefetch as early as possible
-      prefetch((char*)TT.first_entry(pos.key_after(move)));
+      prefetch(TT.first_entry(pos.key_after(move)));
 
       // Check for legality just before making the move
       if (!pos.legal(move, ci.pinned))
 
       // Check for legality just before making the move
       if (!pos.legal(move, ci.pinned))