[Mesa-dev] [PATCH] gallium/util: add util_bitcount64

Matt Turner mattst88 at gmail.com
Tue Sep 30 11:22:36 PDT 2014


On Tue, Sep 30, 2014 at 9:26 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> I'll need this in radeonsi.
> ---
>  src/gallium/auxiliary/util/u_math.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
> index 39bd40f..48d5c31 100644
> --- a/src/gallium/auxiliary/util/u_math.h
> +++ b/src/gallium/auxiliary/util/u_math.h
> @@ -727,6 +727,14 @@ util_bitcount(unsigned n)
>  #endif
>  }
>
> +
> +static INLINE unsigned
> +util_bitcount64(uint64_t n)
> +{
> +       return util_bitcount(n) + util_bitcount(n >> 32);

There's a __builtin_popcountll that operates on a 64-bit value
directly. You should probably use that instead.  We already use it and
test for it with autoconf -- just check #ifdef
HAVE___BUILTIN_POPCOUNTLL.


More information about the mesa-dev mailing list