util: optimize bitcount on OpenCL

Fixes: bfc18b6fb1 ("libagx: drop libagx_popcount")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34661>
This commit is contained in:
Alyssa Rosenzweig
2025-04-22 09:36:59 -04:00
committed by Marge Bot
parent eecfb02463
commit d31ad329c2
+4
View File
@@ -326,6 +326,8 @@ util_bitcount(unsigned n)
{
#if defined(HAVE___BUILTIN_POPCOUNT)
return __builtin_popcount(n);
#elif __OPENCL_VERSION__
return popcount(n);
#else
/* K&R classic bitcount.
*
@@ -366,6 +368,8 @@ util_bitcount64(uint64_t n)
{
#ifdef HAVE___BUILTIN_POPCOUNTLL
return __builtin_popcountll(n);
#elif __OPENCL_VERSION__
return popcount(n);
#else
return util_bitcount((unsigned)n) + util_bitcount((unsigned)(n >> 32));
#endif