| Issue |
176016
|
| Summary |
Missed AVX2 Vectorization
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Disservin
|
GCC vectorized the update_correction_history function here whereas clang simply unrolled it to scalar code.
https://godbolt.org/z/r7MT5z7n4
```c++
void update_correction_history(const Position& pos,
Search::Worker& workerThread,
const int bonus) {
const Color us = pos.side_to_move();
constexpr int nonPawnWeight = 178;
auto& shared = workerThread.sharedHistory;
alignas(16) std::int32_t v[4] = {
shared.pawn_correction_entry(pos)[us].pawn,
shared.minor_piece_correction_entry(pos)[us].minor,
shared.nonpawn_correction_entry<WHITE>(pos)[us].nonPawnWhite,
shared.nonpawn_correction_entry<BLACK>(pos)[us].nonPawnBlack,
};
std::int32_t b[4] = { bonus,
bonus * 156 / 128,
bonus * nonPawnWeight / 128,
bonus * nonPawnWeight / 128 };
auto D = CORRECTION_HISTORY_LIMIT;
for (int i = 0; i < 4; ++i) {
int clamped = std::clamp(b[i], -D, D);
v[i] += clamped - v[i] * std::abs(clamped) / D;
}
shared.pawn_correction_entry(pos).at(us).pawn.from_raw(v[0]);
shared.minor_piece_correction_entry(pos).at(us).minor.from_raw(v[1]);
shared.nonpawn_correction_entry<WHITE>(pos).at(us).nonPawnWhite.from_raw(v[2]);
shared.nonpawn_correction_entry<BLACK>(pos).at(us).nonPawnBlack.from_raw(v[3]);
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs