Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some usages of the pre/post increment operators. #5559

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Jean Gauthier (OuaisBla)
Jekaa
Jerry Donald Watson (jerrydonaldwatson)
jjoshua2
John Doknjas (johndoknjas)
Jonathan Buladas Dumale (SFisGOD)
Jonathan Calovski (Mysseno)
Jonathan McDermid (jonathanmcdermid)
Expand Down
2 changes: 1 addition & 1 deletion src/bitboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void init_magics(PieceType pt, Bitboard table[], Magic magics[]) {
if (HasPext)
m.attacks[pext(b, m.mask)] = reference[size];

size++;
size += 1;
b = (b - m.mask) & m.mask;
} while (b);

Expand Down
13 changes: 6 additions & 7 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,25 @@ DebugExtremes extremes[MaxDebugSlots];

void dbg_hit_on(bool cond, int slot) {

++hit[slot][0];
if (cond)
++hit[slot][1];
hit[slot][0] += 1;
hit[slot][1] += cond;
}

void dbg_mean_of(int64_t value, int slot) {

++mean[slot][0];
mean[slot][0] += 1;
mean[slot][1] += value;
}

void dbg_stdev_of(int64_t value, int slot) {

++stdev[slot][0];
stdev[slot][0] += 1;
stdev[slot][1] += value;
stdev[slot][2] += value * value;
}

void dbg_extremes_of(int64_t value, int slot) {
++extremes[slot][0];
extremes[slot][0] += 1;

int64_t current_max = extremes[slot][1].load();
while (current_max < value && !extremes[slot][1].compare_exchange_weak(current_max, value))
Expand All @@ -339,7 +338,7 @@ void dbg_extremes_of(int64_t value, int slot) {

void dbg_correl_of(int64_t value1, int64_t value2, int slot) {

++correl[slot][0];
correl[slot][0] += 1;
correl[slot][1] += value1;
correl[slot][2] += value1 * value1;
correl[slot][3] += value2;
Expand Down
4 changes: 2 additions & 2 deletions src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ ExtMove* generate<LEGAL>(const Position& pos, ExtMove* moveList) {
while (cur != moveList)
if (((pinned & cur->from_sq()) || cur->from_sq() == ksq || cur->type_of() == EN_PASSANT)
&& !pos.legal(*cur))
*cur = *(--moveList);
*cur = *--moveList;
else
++cur;
cur += 1;

return moveList;
}
Expand Down
14 changes: 7 additions & 7 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Move MovePicker::next_move(bool skipQuiets) {
case EVASION_TT :
case QSEARCH_TT :
case PROBCUT_TT :
++stage;
stage += 1;
return ttMove;

case CAPTURE_INIT :
Expand All @@ -239,7 +239,7 @@ Move MovePicker::next_move(bool skipQuiets) {

score<CAPTURES>();
partial_insertion_sort(cur, endMoves, std::numeric_limits<int>::min());
++stage;
stage += 1;
goto top;

case GOOD_CAPTURE :
Expand All @@ -250,7 +250,7 @@ Move MovePicker::next_move(bool skipQuiets) {
}))
return *(cur - 1);

++stage;
stage += 1;
[[fallthrough]];

case QUIET_INIT :
Expand All @@ -263,7 +263,7 @@ Move MovePicker::next_move(bool skipQuiets) {
partial_insertion_sort(cur, endMoves, quiet_threshold(depth));
}

++stage;
stage += 1;
[[fallthrough]];

case GOOD_QUIET :
Expand All @@ -280,7 +280,7 @@ Move MovePicker::next_move(bool skipQuiets) {
cur = moves;
endMoves = endBadCaptures;

++stage;
stage += 1;
[[fallthrough]];

case BAD_CAPTURE :
Expand All @@ -291,7 +291,7 @@ Move MovePicker::next_move(bool skipQuiets) {
cur = beginBadQuiets;
endMoves = endBadQuiets;

++stage;
stage += 1;
[[fallthrough]];

case BAD_QUIET :
Expand All @@ -305,7 +305,7 @@ Move MovePicker::next_move(bool skipQuiets) {
endMoves = generate<EVASIONS>(pos, cur);

score<EVASIONS>();
++stage;
stage += 1;
[[fallthrough]];

case EVASION :
Expand Down
4 changes: 2 additions & 2 deletions src/nnue/nnue_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ inline void read_leb_128(std::istream& stream, IntType* out, std::size_t count)
}

std::uint8_t byte = buf[buf_pos++];
--bytes_left;
bytes_left -= 1;
result |= (byte & 0x7f) << shift;
shift += 7;

Expand Down Expand Up @@ -236,7 +236,7 @@ inline void write_leb_128(std::ostream& stream, const IntType* values, std::size
{
byte = value & 0x7f;
value >>= 7;
++byte_count;
byte_count += 1;
} while ((byte & 0x40) == 0 ? value != 0 : value != -1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/nnue/nnue_feature_transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@ class FeatureTransformer {
acc[k] = vec_add_16(acc[k], column[k]);
}

for (IndexType k = 0; k < NumRegs; k++)
for (IndexType k = 0; k < NumRegs; ++k)
vec_store(&entryTile[k], acc[k]);
for (IndexType k = 0; k < NumRegs; k++)
for (IndexType k = 0; k < NumRegs; ++k)
vec_store(&accTile[k], acc[k]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/perft.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ uint64_t perft(Position& pos, Depth depth) {
for (const auto& m : MoveList<LEGAL>(pos))
{
if (Root && depth <= 1)
cnt = 1, nodes++;
cnt = 1, nodes += 1;
else
{
pos.do_move(m, st);
Expand Down
8 changes: 4 additions & 4 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void Position::init() {
break;
i = (i == H1(key)) ? H2(key) : H1(key); // Push victim to alternative slot
}
count++;
count += 1;
}
assert(count == 3668);
}
Expand Down Expand Up @@ -697,7 +697,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {

// Increment ply counters. In particular, rule50 will be reset to zero later on
// in case of a capture or a pawn move.
++gamePly;
gamePly += 1;
++st->rule50;
++st->pliesFromNull;

Expand Down Expand Up @@ -836,7 +836,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
dp.piece[dp.dirty_num] = promotion;
dp.from[dp.dirty_num] = SQ_NONE;
dp.to[dp.dirty_num] = to;
dp.dirty_num++;
dp.dirty_num += 1;

// Update hash keys
k ^= Zobrist::psq[pc][to] ^ Zobrist::psq[promotion][to];
Expand Down Expand Up @@ -972,7 +972,7 @@ void Position::undo_move(Move m) {

// Finally point our state pointer back to the previous state
st = st->previous;
--gamePly;
gamePly -= 1;

assert(pos_is_ok());
}
Expand Down
8 changes: 4 additions & 4 deletions src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ inline void Position::put_piece(Piece pc, Square s) {
board[s] = pc;
byTypeBB[ALL_PIECES] |= byTypeBB[type_of(pc)] |= s;
byColorBB[color_of(pc)] |= s;
pieceCount[pc]++;
pieceCount[make_piece(color_of(pc), ALL_PIECES)]++;
pieceCount[pc] += 1;
pieceCount[make_piece(color_of(pc), ALL_PIECES)] += 1;
}

inline void Position::remove_piece(Square s) {
Expand All @@ -353,8 +353,8 @@ inline void Position::remove_piece(Square s) {
byTypeBB[type_of(pc)] ^= s;
byColorBB[color_of(pc)] ^= s;
board[s] = NO_PIECE;
pieceCount[pc]--;
pieceCount[make_piece(color_of(pc), ALL_PIECES)]--;
pieceCount[pc] -= 1;
pieceCount[make_piece(color_of(pc), ALL_PIECES)] -= 1;
}

inline void Position::move_piece(Square from, Square to) {
Expand Down
16 changes: 8 additions & 8 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ void Search::Worker::iterative_deepening() {
pvLast = 0;

if (!threads.increaseDepth)
searchAgainCounter++;
searchAgainCounter += 1;

// MultiPV loop. We perform a full root search for each PV line
for (pvIdx = 0; pvIdx < multiPV; ++pvIdx)
{
if (pvIdx == pvLast)
{
pvFirst = pvLast;
for (pvLast++; pvLast < rootMoves.size(); pvLast++)
for (++pvLast; pvLast < rootMoves.size(); ++pvLast)
if (rootMoves[pvLast].tbRank != rootMoves[pvFirst].tbRank)
break;
}
Expand Down Expand Up @@ -366,7 +366,7 @@ void Search::Worker::iterative_deepening() {
else if (bestValue >= beta)
{
beta = std::min(bestValue + delta, VALUE_INFINITE);
++failedHighCnt;
failedHighCnt += 1;
}
else
break;
Expand Down Expand Up @@ -1147,7 +1147,7 @@ Value Search::Worker::search(

// Decrease reduction for PvNodes (~0 Elo on STC, ~2 Elo on LTC)
if (PvNode)
r--;
r -= 1;

// These reduction adjustments have no proven non-linear scaling

Expand Down Expand Up @@ -1573,7 +1573,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
givesCheck = pos.gives_check(move);
capture = pos.capture_stage(move);

moveCount++;
moveCount += 1;

// Step 6. Pruning
if (bestValue > VALUE_TB_LOSS_IN_MAX_PLY && pos.non_pawn_material(us))
Expand Down Expand Up @@ -1955,7 +1955,7 @@ void syzygy_extend_pv(const OptionsMap& options,
if (legalMoves[0].tbRank != rm.tbRank)
break;

ply++;
ply += 1;

auto& st = sts.emplace_back();
pos.do_move(pvMove, st);
Expand All @@ -1964,7 +1964,7 @@ void syzygy_extend_pv(const OptionsMap& options,
if (config.rootInTB && pos.is_draw(ply))
{
pos.undo_move(pvMove);
ply--;
ply -= 1;
break;
}

Expand Down Expand Up @@ -2015,7 +2015,7 @@ void syzygy_extend_pv(const OptionsMap& options,
if (!config.rootInTB || config.cardinality > 0)
break;

ply++;
ply += 1;

Move& pvMove = legalMoves[0].pv[0];
rootMove.pv.push_back(pvMove);
Expand Down
Loading
Loading