On Mon, 01 Sep 2025 21:33:40 +0200 "Sanjoy Mahajan" <[email protected]> wrote:
> I have two 64-bit laptops, both running Debian unstable.  On the newish
> one, which has an Intel(R) Core(TM) i7-5600U CPU, the mtxrun works fine
> (no "illegal instruction").
> 
> On the ancient one, which has an Intel(R) Core(TM)2 Duo CPU T9300, it
> fails right away.

On the ancient laptop, I applied the attached patch and rebuilt
libmimalloc3.  The patch completely avoids the popcnt instruction and
forces the use of _mi_popcount_generic().  Now mtxrun works (so the
long-missing formats have finally been generated).

Of course, this patch is not a viable solution in general.  But it
indicates a problem in the test for whether the CPU has popcnt.  So, it
might point someone who understands how this test should work toward a
proper patch.

--- a/include/mimalloc/bits.h	2025-03-28 22:19:26.000000000 +0100
+++ b/include/mimalloc/bits.h	2025-09-03 10:30:24.521614879 +0200
@@ -187,12 +187,7 @@
 
 static inline size_t mi_popcount(size_t x) {
   #if defined(__GNUC__) && (MI_ARCH_X64 || MI_ARCH_X86)
-    #if !defined(__BMI1__)
-    if mi_unlikely(!_mi_cpu_has_popcnt) { return _mi_popcount_generic(x); }
-    #endif
-    size_t r;
-    __asm ("popcnt\t%1,%0" : "=r"(r) : "r"(x) : "cc");
-    return r;
+    return _mi_popcount_generic(x);
   #elif defined(_MSC_VER) && (MI_ARCH_X64 || MI_ARCH_X86)
     #if !defined(__BMI1__)
     if mi_unlikely(!_mi_cpu_has_popcnt) { return _mi_popcount_generic(x); }

-- 
-Sanjoy

Reply via email to