}
#endif
+
+
+#ifdef HAS_NATIVE_POPCOUNT
+static inline unsigned int popcount(unsigned int n){
+ asm ("popcnt %1, %0" : "=r" (n) : "0" (n));
+ return n;
+}
+
+static inline unsigned int popcount8(unsigned int n) {
+ return popcount(n & 0xff);
+}
+
+static inline unsigned int _fast_popcount(int x)
+{
+ return popcount8(x);
+}
+
+
+#else
+
static const unsigned int _popCount[] = {
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
};
-static inline unsigned int
-_fast_popcount2(int x)
-{
- uint m1 = 0x55555555;
- uint m2 = 0x33333333;
- uint m4 = 0x0f0f0f0f;
- x -= (x >> 1) & m1;
- x = (x & m2) + ((x >> 2) & m2);
- x = (x + (x >> 4)) & m4;
- x += x >> 8;
- return (x + (x >> 16)) & 0x3f;
-}
-
-static inline unsigned int
-_fast_popcount3(int x)
-{
- uint m1 = 0x55555555;
- uint m2 = 0xc30c30c3;
- x -= (x >> 1) & m1;
- x = (x & m2) + ((x >> 2) & m2) + ((x >> 4) & m2);
- x += x >> 6;
- return (x + (x >> 12) + (x >> 24)) & 0x3f;
-}
static inline unsigned int
_fast_popcount(int x) {
return _popCount[x];
}
+#endif
+
+
static unsigned int __selecttbl[8*256];
static int built = 0;