--- src/blister.c.orig 2022-08-18 14:51:32.000000000 -0600
+++ src/blister.c 2022-08-22 15:15:48.900018807 -0600
@@ -840,6 +840,29 @@ void ConvBlist (
**
*F COUNT_TRUES_BLOCK( <block> ) . . . . . . . . . . . count number of trues
*/
+#ifdef __x86_64__
+#include <cpuid.h>
+static UInt __attribute__((target ("popcnt"))) fast_COUNT_TRUES_BLOCK(UInt block)
+{
+ return __builtin_popcountl(block);
+}
+
+static UInt slow_COUNT_TRUES_BLOCK(UInt block)
+{
+ return __builtin_popcountl(block);
+}
+
+static UInt (*resolve_COUNT_TRUES_BLOCK(void))(UInt block)
+{
+ unsigned int eax, ebx, ecx, edx;
+ return (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & bit_POPCNT) != 0)
+ ? &fast_COUNT_TRUES_BLOCK
+ : &slow_COUNT_TRUES_BLOCK;
+}
+
+UInt __attribute__((ifunc ("resolve_COUNT_TRUES_BLOCK")))
+COUNT_TRUES_BLOCK(UInt block);
+#else
UInt COUNT_TRUES_BLOCK(UInt block)
{
#if USE_POPCNT && defined(HAVE___BUILTIN_POPCOUNTL)
@@ -864,6 +887,7 @@ UInt COUNT_TRUES_BLOCK(UInt block)
return block;
#endif
}
+#endif
/****************************************************************************
**