diff options
author | Marek Olšák <[email protected]> | 2014-09-24 18:26:21 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2014-10-04 15:16:14 +0200 |
commit | af4f5a7c97f3ab47bbd21aa7c27d0c0aaf01f959 (patch) | |
tree | 7f39a5ab1ae4ae0a490bb7780ed393aefce4c87b /src | |
parent | 837907b8b3bd290e2fa8092579a4855097ecab9f (diff) |
gallium/util: add util_bitcount64
I'll need this in radeonsi.
v2: use __builtin_popcountll if available
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 39bd40fa153..f95c11166e8 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -727,6 +727,18 @@ util_bitcount(unsigned n) #endif } + +static INLINE unsigned +util_bitcount64(uint64_t n) +{ +#ifdef HAVE___BUILTIN_POPCOUNTLL + return __builtin_popcountll(n); +#else + return util_bitcount(n) + util_bitcount(n >> 32); +#endif +} + + /** * Reverse bits in n * Algorithm taken from: |