ghc-prim: Use population count appropriate for platform
authorBen Gamari <bgamari.foss@gmail.com>
Tue, 21 Oct 2014 20:00:02 +0000 (15:00 -0500)
committerAustin Seipp <austin@well-typed.com>
Tue, 21 Oct 2014 20:00:02 +0000 (15:00 -0500)
Summary:
This #ifdef was previously x86-centric and consequently the 64-bit
implementation was chosen for ARM.

Reviewers: rwbarton, hvr, austin, tibbe

Reviewed By: hvr, austin, tibbe

Subscribers: hvr, thomie, carter, ezyang, simonmar

Differential Revision: https://phabricator.haskell.org/D312

libraries/ghc-prim/cbits/popcnt.c

index fc44ee7..70662e8 100644 (file)
@@ -1,4 +1,5 @@
 #include "Rts.h"
+#include "MachDeps.h"
 
 static const unsigned char popcount_tab[] =
 {
@@ -51,7 +52,7 @@ hs_popcnt64(StgWord64 x)
       popcount_tab[(unsigned char)(x >> 56)];
 }
 
-#ifdef i386_HOST_ARCH
+#if WORD_SIZE_IN_BITS == 32
 
 extern StgWord hs_popcnt(StgWord x);
 StgWord
@@ -63,7 +64,7 @@ hs_popcnt(StgWord x)
       popcount_tab[(unsigned char)(x >> 24)];
 }
 
-#else
+#elif WORD_SIZE_IN_BITS == 64
 
 extern StgWord hs_popcnt(StgWord x);
 StgWord
@@ -79,4 +80,8 @@ hs_popcnt(StgWord x)
       popcount_tab[(unsigned char)(x >> 56)];
 }
 
+#else
+
+#error Unknown machine word size
+
 #endif