1 dnl AMD64 mpn_hamdist
-- hamming distance.
3 dnl Copyright
2008, 2010-2012 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
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.
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
20 dnl
or both
in parallel
, as here.
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
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
/.
31 include(`..
/config.m4
')
42 C This is very straightforward 2-way unrolled code.
45 C * Write something less basic. It should not be hard to reach 1.5 c/l with
63 lea (ap,n,8), ap C point at A operand end
64 lea (bp,n,8), bp C point at B operand end
70 L(1): .byte 0xf3,0x49,0x0f,0xb8,0xc0 C popcnt %r8, %rax
71 xor R32(%r10), R32(%r10)
78 L(2): mov 8(ap,n,8), %r9
79 .byte 0xf3,0x49,0x0f,0xb8,0xc0 C popcnt %r8, %rax
81 .byte 0xf3,0x4d,0x0f,0xb8,0xd1 C popcnt %r9, %r10
84 lea (%r10, %rax), %rax
89 L(top): mov (ap,n,8), %r8
90 lea (%r10, %rax), %rax
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
100 lea (%r10, %rax), %rax