gallium/util: add util_bitcount64
authorMarek Olšák <marek.olsak@amd.com>
Wed, 24 Sep 2014 16:26:21 +0000 (18:26 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 4 Oct 2014 13:16:14 +0000 (15:16 +0200)
I'll need this in radeonsi.

v2: use __builtin_popcountll if available

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/auxiliary/util/u_math.h

index 39bd40f..f95c111 100644 (file)
@@ -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: