summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bit.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bit.h b/src/bit.h
index 21a8076..7f71d04 100644
--- a/src/bit.h
+++ b/src/bit.h
@@ -350,7 +350,8 @@ UINT_OVERLOADS(FIRST_TRAILING_ONE)
#define HAS_SINGLE_BIT(type, suffix, width) \
static inline bool has_single_bit##suffix(type n) { \
- return n && !(n & (n - 1)); \
+ /** Branchless n && !(n & (n - 1)) */ \
+ return n - 1 < (n ^ (n - 1)); \
}
UINT_OVERLOADS(ROTATE_LEFT)