From d31ad329c2505b9cedb39bec61a8f2b9c58b6289 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 22 Apr 2025 09:36:59 -0400 Subject: [PATCH] util: optimize bitcount on OpenCL Fixes: bfc18b6fb16 ("libagx: drop libagx_popcount") Signed-off-by: Alyssa Rosenzweig Reviewed-by: Mary Guillemard Part-of: --- src/util/bitscan.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/bitscan.h b/src/util/bitscan.h index 541bf79d076..21bdafd1e49 100644 --- a/src/util/bitscan.h +++ b/src/util/bitscan.h @@ -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