Skip to content

Commit

Permalink
__lzcnt64 alternative for arm64 (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed Jan 7, 2024
1 parent 615b723 commit 78cd91e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dev/src/lobster/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,16 @@ inline int PopCount(uint64_t val) {

inline int HighZeroBits(uint64_t val) {
#ifdef _MSC_VER
return (int)__lzcnt64(val);
#ifndef _M_ARM64
return (int)__lzcnt64(val);
#else
unsigned long index;
int d = (int)sizeof(uint64_t) * 8;
if (_BitScanReverse64(&index, val)) {
d = d - 1 - index;
}
return d;
#endif
#else
return __builtin_clzll(val);
#endif
Expand Down

0 comments on commit 78cd91e

Please sign in to comment.