diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-11-11 13:46:21 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-11-11 13:47:00 -0500 |
commit | 56e35928daaec12c97ccc4707546f669db1d909d (patch) | |
tree | 9db552bd2e1f69a96dfaaee4c215b0ed4f87b4f0 /src/bit.h | |
parent | 640fa83406bb8c08d971be68b32b7e222e92e286 (diff) | |
download | bfs-56e35928daaec12c97ccc4707546f669db1d909d.tar.xz |
Revert "bit: Implement a branchless has_single_bit()"
Doesn't work for the highest bit due to overflow.
This reverts commit 208376ef99da243545efcd6fb02d3469b4c068ed.
Diffstat (limited to 'src/bit.h')
-rw-r--r-- | src/bit.h | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -350,8 +350,7 @@ UINT_OVERLOADS(FIRST_TRAILING_ONE) #define HAS_SINGLE_BIT(type, suffix, width) \ static inline bool has_single_bit##suffix(type n) { \ - /** Branchless n && !(n & (n - 1)) */ \ - return n < (n ^ (n - 1)) + 1; \ + return n && !(n & (n - 1)); \ } UINT_OVERLOADS(ROTATE_LEFT) |