github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/x86_64/k10/hamdist.asm (about) 1 dnl AMD64 mpn_hamdist -- hamming distance. 2 3 dnl Copyright 2008, 2010-2012 Free Software Foundation, Inc. 4 5 dnl This file is part of the GNU MP Library. 6 dnl 7 dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 dnl it under the terms of either: 9 dnl 10 dnl * the GNU Lesser General Public License as published by the Free 11 dnl Software Foundation; either version 3 of the License, or (at your 12 dnl option) any later version. 13 dnl 14 dnl or 15 dnl 16 dnl * the GNU General Public License as published by the Free Software 17 dnl Foundation; either version 2 of the License, or (at your option) any 18 dnl later version. 19 dnl 20 dnl or both in parallel, as here. 21 dnl 22 dnl The GNU MP Library is distributed in the hope that it will be useful, but 23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25 dnl for more details. 26 dnl 27 dnl You should have received copies of the GNU General Public License and the 28 dnl GNU Lesser General Public License along with the GNU MP Library. If not, 29 dnl see https://www.gnu.org/licenses/. 30 31 include(`../config.m4') 32 33 C cycles/limb 34 C AMD K8,K9 n/a 35 C AMD K10 2 36 C Intel P4 n/a 37 C Intel core2 n/a 38 C Intel corei 2.05 39 C Intel atom n/a 40 C VIA nano n/a 41 42 C This is very straightforward 2-way unrolled code. 43 44 C TODO 45 C * Write something less basic. It should not be hard to reach 1.5 c/l with 46 C 4-way unrolling. 47 48 define(`ap', `%rdi') 49 define(`bp', `%rsi') 50 define(`n', `%rdx') 51 52 ABI_SUPPORT(DOS64) 53 ABI_SUPPORT(STD64) 54 55 ASM_START() 56 TEXT 57 ALIGN(32) 58 PROLOGUE(mpn_hamdist) 59 FUNC_ENTRY(3) 60 mov (ap), %r8 61 xor (bp), %r8 62 63 lea (ap,n,8), ap C point at A operand end 64 lea (bp,n,8), bp C point at B operand end 65 neg n 66 67 bt $0, R32(n) 68 jnc L(2) 69 70 L(1): .byte 0xf3,0x49,0x0f,0xb8,0xc0 C popcnt %r8, %rax 71 xor R32(%r10), R32(%r10) 72 add $1, n 73 js L(top) 74 FUNC_EXIT() 75 ret 76 77 ALIGN(16) 78 L(2): mov 8(ap,n,8), %r9 79 .byte 0xf3,0x49,0x0f,0xb8,0xc0 C popcnt %r8, %rax 80 xor 8(bp,n,8), %r9 81 .byte 0xf3,0x4d,0x0f,0xb8,0xd1 C popcnt %r9, %r10 82 add $2, n 83 js L(top) 84 lea (%r10, %rax), %rax 85 FUNC_EXIT() 86 ret 87 88 ALIGN(16) 89 L(top): mov (ap,n,8), %r8 90 lea (%r10, %rax), %rax 91 mov 8(ap,n,8), %r9 92 xor (bp,n,8), %r8 93 xor 8(bp,n,8), %r9 94 .byte 0xf3,0x49,0x0f,0xb8,0xc8 C popcnt %r8, %rcx 95 lea (%rcx, %rax), %rax 96 .byte 0xf3,0x4d,0x0f,0xb8,0xd1 C popcnt %r9, %r10 97 add $2, n 98 js L(top) 99 100 lea (%r10, %rax), %rax 101 FUNC_EXIT() 102 ret 103 EPILOGUE()