Add population count primop
Modern CPUs have a POPCNT
instruction for efficient population count. This instruction can be used to implement various data structures.
I propose we add the following set of primops
popCnt8# :: Word# -> Word#
popCnt16# :: Word# -> Word#
popCnt32# :: Word# -> Word#
popCnt64# :: Word64# -> Word#
popCnt# :: Word# -> Word#
(We use Word#
for all functions except the 64 bit version as there are no Word8
, Word16#
and Word32#
types).
Each primop compiles into either a single POPCNT
instruction or a call to some fallback function, implemented in C.
Trac metadata
Trac field | Value |
---|---|
Version | 7.2.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |