diff options
| author | Scott Gasch <[email protected]> | 2026-10-25 11:20:24 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-10-25 11:20:41 -0700 |
| commit | c1e8cefc7bf0c4017dda24b0486806ce3304a7ae (patch) | |
| tree | da5cfe55fe0af85c615db8c68320d53d1f67cf5c /src/chess.h | |
| parent | 455accb4cbb1777cb553b6d75136521c6b8d1c01 (diff) | |
x86.asm/x64.asm were already mostly dead weight -- GetAttacks's real
asm body was retired 2026-09-06 (section 7 of
board_representation/MIGRATION.md), and LockDecrement/
CanUseParallelOpcodes/ParallelCompareUlong/ParallelCompareVector had
zero remaining callers (confirmed by grep before deleting anything).
What was still real and load-bearing:
- CountBits/FirstBit/LastBit: popcount/bsf/bsr CDECL calls. Already
had faster, compiler-intrinsic replacements sitting right next to
them in chess.h (FastCountBits/FastFirstBit/FastLastBit, via
__builtin_popcountll/__builtin_ctzll/__builtin_clzll with -mpopcnt)
that per-file #ifndef CROUTINES blocks in board.c/eval.c/generate.c/
probe.c/recogn.c were already redirecting individual call sites to.
Promoted that redirect to the plain names unconditionally
(#define CountBits FastCountBits etc. in chess.h) and dropped the
now-always-true CROUTINES guards in those five files -- CountBits'
real asm body was a Kernighan bit-clearing loop (~23 cycles/op per
gmake TEST=1's own benchmark), not even O(1), so this is strictly
faster as well as removing the toolchain dependency.
- LockCompareExchange/LockIncrement: real atomics backing
AcquireSpinLock/TryAcquireSpinLock/ReleaseSpinLock (util.c) and the
move-pool allocator (gamelist.c). Replaced with static inline
wrappers over __sync_val_compare_and_swap/__sync_add_and_fetch --
same CAS/atomic-add semantics as the retired `lock cmpxchg`/
`lock xadd` instructions.
Removes the yasm/nasm build dependency entirely: GNUmakefile's
NASM/NASMFLAGS variables, the CROUTINES flag, the .asm->.o build rule,
and x86.o/x64.o from every OBJS list. x86.asm/x64.asm deleted outright
(git history keeps them if ever needed again). The ASM=1 debug mode
(-S -fverbose-asm, a C-compiler assembly-listing dump, unrelated to
the deleted files despite the similar name) is untouched.
Verified: clean build with no yasm/nasm invocation anywhere in the
log, a clean DEBUG=1 TEST=1 self-test run, and node-count parity
against the previous commit on all three curated suites at sd10
(4,003,856 / 22,308,015 / 26,868,016 on both sides) -- confirms this
is a pure substitution with zero behavioral change, not just "doesn't
crash."
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/chess.h')
| -rwxr-xr-x | src/chess.h | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/src/chess.h b/src/chess.h index 2942f0a..97c877c 100755 --- a/src/chess.h +++ b/src/chess.h @@ -5214,11 +5214,18 @@ FastCoorFromBitBoardRank1ToRank8(IN OUT BITBOARD *pbb) return c; } -#ifdef CROUTINES -#define CountBits SlowCountBits -#define FirstBit SlowFirstBit -#define LastBit SlowLastBit -#endif +// 2026-10-25: CountBits/FirstBit/LastBit used to be real extern CDECL +// calls into x86.asm/x64.asm (retired -- see FastCountBits/ +// FastFirstBit/FastLastBit above, the compiler-intrinsic replacements +// that made the asm versions' only remaining edge, "CROUTINES=1 is +// slower," meaningless: the intrinsics are both correct AND faster). +// Every plain-name call site now just resolves to the fast inline +// version directly; Slow*/DeBruijnFirstBit above remain as the +// cross-check reference implementations FastCountBits's own ASSERT +// and testbitboard.c's benchmarks compare against. +#define CountBits FastCountBits +#define FirstBit FastFirstBit +#define LastBit FastLastBit COOR CoorFromBitBoardRank8ToRank1(BITBOARD *pbb); @@ -5302,37 +5309,28 @@ PawnMaterial(IN POSITION *pos, IN ULONG color) return FastCountBits(pos->bbPawns[color]) * VALUE_PAWN; } -// -// x86.asm -// -ULONG CDECL -CountBits(BITBOARD bb); - -ULONG CDECL -FirstBit(BITBOARD bb); - -ULONG CDECL -LastBit(BITBOARD bb); - -ULONG CDECL -LockCompareExchange(volatile void *pDest, - ULONG uExch, - ULONG uComp); - -ULONG CDECL -LockIncrement(volatile void *pDest); - -ULONG CDECL -LockDecrement(volatile void *pDest); - -FLAG CDECL -CanUseParallelOpcodes(); - -ULONG CDECL -ParallelCompareUlong(ULONG uComparand, void *pComparators); +// 2026-10-25: were extern CDECL calls into x86.asm/x64.asm (retired). +// CountBits/FirstBit/LastBit are handled above (macros onto +// FastCountBits/FastFirstBit/FastLastBit). LockDecrement/ +// CanUseParallelOpcodes/ParallelCompareUlong/ParallelCompareVector had +// zero real callers (confirmed by grep before deleting the asm) -- +// gone outright, nothing to replace. LockCompareExchange/LockIncrement +// are real (AcquireSpinLock/TryAcquireSpinLock/ReleaseSpinLock in +// util.c; gamelist.c's move-pool allocator) -- same CAS/atomic-add +// semantics as the retired `lock cmpxchg`/`lock xadd` asm, via +// compiler builtins instead. +static ULONG INLINE +LockCompareExchange(volatile void *pDest, ULONG uExch, ULONG uComp) +{ + return (ULONG)__sync_val_compare_and_swap((volatile ULONG *)pDest, + uComp, uExch); +} -ULONG CDECL -ParallelCompareVector(void *pComparand, void *pComparators); +static ULONG INLINE +LockIncrement(volatile void *pDest) +{ + return (ULONG)__sync_add_and_fetch((volatile ULONG *)pDest, 1); +} // board_representation/MIGRATION.md sections 3/6/7: bbPieces/bbPawns- // backed GetAttacks primitive. Verified correct (20,000-position |
