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

Michel Dänzer michel at daenzer.net
Thu Oct 2 19:26:36 PDT 2014


On 03.10.2014 02:26, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> I'll need this in radeonsi.
>
> v2: use __builtin_popcountll if available
> ---
>   src/gallium/auxiliary/util/u_math.h | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
> index 39bd40f..f95c111 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
> +}

Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>


-- 
Earthling Michel Dänzer            |                  http://www.amd.com
Libre software enthusiast          |                Mesa and X developer


More information about the mesa-dev mailing list