[commit: ghc] master: ghc-prim: Use population count appropriate for platform (9f29e03)

git at git.haskell.org git at git.haskell.org
Tue Oct 21 21:50:33 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9f29e032a0a0fa3f7685d8e3553cc64e33cc317d/ghc

>---------------------------------------------------------------

commit 9f29e032a0a0fa3f7685d8e3553cc64e33cc317d
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Tue Oct 21 15:00:02 2014 -0500

    ghc-prim: Use population count appropriate for platform
    
    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


>---------------------------------------------------------------

9f29e032a0a0fa3f7685d8e3553cc64e33cc317d
 libraries/ghc-prim/cbits/popcnt.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libraries/ghc-prim/cbits/popcnt.c b/libraries/ghc-prim/cbits/popcnt.c
index fc44ee7..70662e8 100644
--- a/libraries/ghc-prim/cbits/popcnt.c
+++ b/libraries/ghc-prim/cbits/popcnt.c
@@ -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



More information about the ghc-commits mailing list