From 56e35928daaec12c97ccc4707546f669db1d909d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 11 Nov 2023 13:46:21 -0500 Subject: Revert "bit: Implement a branchless has_single_bit()" Doesn't work for the highest bit due to overflow. This reverts commit 208376ef99da243545efcd6fb02d3469b4c068ed. --- src/bit.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/bit.h') diff --git a/src/bit.h b/src/bit.h index e680fed..21a8076 100644 --- a/src/bit.h +++ b/src/bit.h @@ -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) -- cgit v1.2.3