diff options
Diffstat (limited to 'runtime/utils.h')
-rw-r--r-- | runtime/utils.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/utils.h b/runtime/utils.h index 0c11610..cd04c3f 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -289,6 +289,12 @@ static constexpr int CTZ(T x) { } template<typename T> +static inline int WhichPowerOf2(T x) { + DCHECK((x != 0) && IsPowerOfTwo(x)); + return CTZ(x); +} + +template<typename T> static constexpr int POPCOUNT(T x) { return (sizeof(T) == sizeof(uint32_t)) ? __builtin_popcount(x) |