summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2003-11-06 01:24:25 +0000
committerpeter <peter@FreeBSD.org>2003-11-06 01:24:25 +0000
commitbe32bf80013e9d5a8db96d9daaa5c555cc972c15 (patch)
tree60231ee958121a2bc115413640571fe508927597 /sys
parent776db871bd81c1be4a8245d7e02cfd23378f0f9a (diff)
downloadFreeBSD-src-be32bf80013e9d5a8db96d9daaa5c555cc972c15.zip
FreeBSD-src-be32bf80013e9d5a8db96d9daaa5c555cc972c15.tar.gz
OK, this might be a bit silly, but add another popcnt() candidate.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/mp_machdep.c6
-rw-r--r--sys/i386/i386/mp_machdep.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index a826dd8..f0b1d43 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -915,6 +915,12 @@ smp_tlb_shootdown(u_int vector, vm_offset_t addr1, vm_offset_t addr2)
* -mcpu=pentiumpro and -march=pentiumpro then gcc-3.1 will use
* an imull, and in that case it is faster. In most other cases
* it appears slightly slower.
+ *
+ * Another variant (also from fortune):
+ * #define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255)
+ * #define BX_(x) ((x) - (((x)>>1)&0x77777777) \
+ * - (((x)>>2)&0x33333333) \
+ * - (((x)>>3)&0x11111111))
*/
static __inline u_int32_t
popcnt(u_int32_t m)
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index a826dd8..f0b1d43 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -915,6 +915,12 @@ smp_tlb_shootdown(u_int vector, vm_offset_t addr1, vm_offset_t addr2)
* -mcpu=pentiumpro and -march=pentiumpro then gcc-3.1 will use
* an imull, and in that case it is faster. In most other cases
* it appears slightly slower.
+ *
+ * Another variant (also from fortune):
+ * #define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255)
+ * #define BX_(x) ((x) - (((x)>>1)&0x77777777) \
+ * - (((x)>>2)&0x33333333) \
+ * - (((x)>>3)&0x11111111))
*/
static __inline u_int32_t
popcnt(u_int32_t m)
OpenPOWER on IntegriCloud