port get_changed_pieces to ARM NEON

passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 71968 W: 18833 L: 18489 D: 34646
Ptnml(0-2): 192, 7310, 20643, 7640, 199
https://tests.stockfishchess.org/tests/view/69509e5c572093c1986d7a0a

closes https://github.com/official-stockfish/Stockfish/pull/6512

No functional change
This commit is contained in:
anematode
2026-01-01 16:04:43 +01:00
committed by Joost VandeVondele
parent ced9f69834
commit aeb3bf33a9
2 changed files with 16 additions and 3 deletions
+12
View File
@@ -645,6 +645,18 @@ Bitboard get_changed_pieces(const std::array<Piece, SQUARE_NB>& oldPieces,
sameBB |= static_cast<Bitboard>(equalMask) << i; sameBB |= static_cast<Bitboard>(equalMask) << i;
} }
return ~sameBB; return ~sameBB;
#elif defined(USE_NEON)
uint8x16x4_t old_v = vld4q_u8(reinterpret_cast<const uint8_t*>(oldPieces.data()));
uint8x16x4_t new_v = vld4q_u8(reinterpret_cast<const uint8_t*>(newPieces.data()));
auto cmp = [=](const int i) { return vceqq_u8(old_v.val[i], new_v.val[i]); };
uint8x16_t cmp0_1 = vsriq_n_u8(cmp(1), cmp(0), 1);
uint8x16_t cmp2_3 = vsriq_n_u8(cmp(3), cmp(2), 1);
uint8x16_t merged = vsriq_n_u8(cmp2_3, cmp0_1, 2);
merged = vsriq_n_u8(merged, merged, 4);
uint8x8_t sameBB = vshrn_n_u16(vreinterpretq_u16_u8(merged), 4);
return ~vget_lane_u64(vreinterpret_u64_u8(sameBB), 0);
#else #else
Bitboard changed = 0; Bitboard changed = 0;
+2 -1
View File
@@ -315,7 +315,8 @@ void Search::Worker::iterative_deepening() {
for (Color c : {WHITE, BLACK}) for (Color c : {WHITE, BLACK})
for (int i = 0; i < UINT_16_HISTORY_SIZE; i++) for (int i = 0; i < UINT_16_HISTORY_SIZE; i++)
mainHistory[c][i] = (mainHistory[c][i] - mainHistoryDefault) * 3 / 4 + mainHistoryDefault; mainHistory[c][i] =
(mainHistory[c][i] - mainHistoryDefault) * 3 / 4 + mainHistoryDefault;
// Iterative deepening loop until requested to stop or the target depth is reached // Iterative deepening loop until requested to stop or the target depth is reached
while (++rootDepth < MAX_PLY && !threads.stop while (++rootDepth < MAX_PLY && !threads.stop