Mesa (master): gallium/util: add util_bitcount64
Marek Olšák
mareko at kemper.freedesktop.org
Sat Oct 4 13:37:11 UTC 2014
Module: Mesa
Branch: master
Commit: af4f5a7c97f3ab47bbd21aa7c27d0c0aaf01f959
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af4f5a7c97f3ab47bbd21aa7c27d0c0aaf01f959
Author: Marek Olšák <marek.olsak at amd.com>
Date: Wed Sep 24 18:26:21 2014 +0200
gallium/util: add util_bitcount64
I'll need this in radeonsi.
v2: use __builtin_popcountll if available
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
---
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
+}
+
+
/**
* Reverse bits in n
* Algorithm taken from:
More information about the mesa-commit
mailing list