dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C AMD K8,K9 n/a
C AMD K10 1.39
C AMD bd1 4
C AMD bd2 4
C AMD bd3 ?
C AMD bd4 ?
C AMD zen 0.72
C AMD bobcat 5.78
C AMD jaguar 1.27
C Intel P4 n/a
C Intel core2 n/a
C Intel NHM 1.04
C Intel SBR 1.02
C Intel IBR 1.0
C Intel HWL 1.0
C Intel BWL 1.0
C Intel SKL 1.0
C Intel atom n/a
C Intel SLM 1.34
C VIA nano n/a
C TODO
C * We could approach 0.5 c/l for AMD Zen with more unrolling. That would
C not cause any additional feed-in overhead as we already use a jump table.
C * An AVX pshufb based variant should approach 0.5 c/l on Haswell and later
C Intel hardware. Perhaps mix such a loop with popcnt instructions.
C * The random placement of the L0, L1, L2, etc blocks are due to branch
C shortening.
define(`up', `%rdi')
define(`n', `%rsi')
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
ASM_START()
TEXT ALIGN(32)
PROLOGUE(mpn_popcount)
FUNC_ENTRY(2)
mov R32(n), R32(%r8) and $7, R32(%r8)
.byte0xf3,0x48,0x0f,0xb8,0x07 C popcnt (up), %rax xor R32(%rcx), R32(%rcx)
L(3): .byte0xf3,0x4c,0x0f,0xb8,0x57,0x08 C popcnt 8(up), %r10
.byte0xf3,0x4c,0x0f,0xb8,0x5f,0x10 C popcnt 16(up), %r11 add $24, up sub $8, n jg L(e34) add %r10, %rax add %r11, %rax
L(s1): FUNC_EXIT() ret
L(1): sub $8, n
jle L(s1)
.byte0xf3,0x4c,0x0f,0xb8,0x47,0x08 C popcnt 8(up), %r8
.byte0xf3,0x4c,0x0f,0xb8,0x4f,0x10 C popcnt 16(up), %r9 add $8, up jmp L(e12)
L(7): .byte0xf3,0x4c,0x0f,0xb8,0x57,0x08 C popcnt 0x8(%rdi),%r10
.byte0xf3,0x4c,0x0f,0xb8,0x5f,0x10 C popcnt 0x10(%rdi),%r11 add $-8, up jmp L(e07)
L(0): .byte0xf3,0x48,0x0f,0xb8,0x4f,0x08 C popcnt 0x8(%rdi),%rcx
.byte0xf3,0x4c,0x0f,0xb8,0x57,0x10 C popcnt 0x10(%rdi),%r10
.byte0xf3,0x4c,0x0f,0xb8,0x5f,0x18 C popcnt 0x18(%rdi),%r11 jmp L(e07)
L(4): .byte0xf3,0x48,0x0f,0xb8,0x4f,0x08 C popcnt 0x8(%rdi),%rcx
.byte0xf3,0x4c,0x0f,0xb8,0x57,0x10 C popcnt 0x10(%rdi),%r10
.byte0xf3,0x4c,0x0f,0xb8,0x5f,0x18 C popcnt 0x18(%rdi),%r11 add $32, up sub $8, n
jle L(x4)
ALIGN(16)
L(top):
L(e34): .byte0xf3,0x4c,0x0f,0xb8,0x07 C popcnt (%rdi),%r8
.byte0xf3,0x4c,0x0f,0xb8,0x4f,0x08 C popcnt 0x8(%rdi),%r9 add %r10, %rcx add %r11, %rax
L(e12): .byte0xf3,0x4c,0x0f,0xb8,0x57,0x10 C popcnt 0x10(%rdi),%r10
.byte0xf3,0x4c,0x0f,0xb8,0x5f,0x18 C popcnt 0x18(%rdi),%r11 add %r8, %rcx add %r9, %rax
L(e07): .byte0xf3,0x4c,0x0f,0xb8,0x47,0x20 C popcnt 0x20(%rdi),%r8
.byte0xf3,0x4c,0x0f,0xb8,0x4f,0x28 C popcnt 0x28(%rdi),%r9 add %r10, %rcx add %r11, %rax
L(e56): .byte0xf3,0x4c,0x0f,0xb8,0x57,0x30 C popcnt 0x30(%rdi),%r10
.byte0xf3,0x4c,0x0f,0xb8,0x5f,0x38 C popcnt 0x38(%rdi),%r11 add $64, up add %r8, %rcx add %r9, %rax sub $8, n jg L(top)
L(2): .byte0xf3,0x48,0x0f,0xb8,0x4f,0x08 C popcnt 0x8(%rdi),%rcx sub $8, n
jle L(x2)
.byte0xf3,0x4c,0x0f,0xb8,0x47,0x10 C popcnt 0x10(%rdi),%r8
.byte0xf3,0x4c,0x0f,0xb8,0x4f,0x18 C popcnt 0x18(%rdi),%r9 add $16, up jmp L(e12)
L(5): .byte0xf3,0x4c,0x0f,0xb8,0x47,0x08 C popcnt 0x8(%rdi),%r8
.byte0xf3,0x4c,0x0f,0xb8,0x4f,0x10 C popcnt 0x10(%rdi),%r9 add $-24, up jmp L(e56)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.