Debian Codegraph @

mpn/x86_64/k10/hamdist.asm

raw
1 dnl AMD64 mpn_hamdist -- hamming distance.
2
3 dnl Copyright 2008, 2010-2012, 2017 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 -
35 C AMD K10 2.0 =
36 C AMD bd1 ~4.4 =
37 C AMD bd2 ~4.4 =
38 C AMD bd3
39 C AMD bd4
40 C AMD bobcat 7.55 =
41 C AMD jaguar 2.52 -
42 C Intel P4 -
43 C Intel core2 -
44 C Intel NHM 2.03 +
45 C Intel SBR 2.01 +
46 C Intel IBR 1.96 +
47 C Intel HWL 1.64 =
48 C Intel BWL 1.56 -
49 C Intel SKL 1.52 =
50 C Intel atom
51 C Intel SLM 3.0 -
52 C VIA nano
53
54 define(`ap', `%rdi')
55 define(`bp', `%rsi')
56 define(`n', `%rdx')
57
58 ABI_SUPPORT(DOS64)
59 ABI_SUPPORT(STD64)
60
61 ASM_START()
62 TEXT
63 ALIGN(32)
64 PROLOGUE(mpn_hamdist)
65 FUNC_ENTRY(3)
66 mov (ap), %r8
67 xor (bp), %r8
68
69 lea (ap,n,8), ap C point at A operand end
70 lea (bp,n,8), bp C point at B operand end
71 neg n
72
73 test $1, R8(n)
74 jz L(2)
75
76 L(1): .byte 0xf3,0x49,0x0f,0xb8,0xc0 C popcnt %r8, %rax
77 xor R32(%r10), R32(%r10)
78 inc n
79 js L(top)
80 FUNC_EXIT()
81 ret
82
83 ALIGN(16)
84 L(2): mov 8(ap,n,8), %r9
85 .byte 0xf3,0x49,0x0f,0xb8,0xc0 C popcnt %r8, %rax
86 xor 8(bp,n,8), %r9
87 .byte 0xf3,0x4d,0x0f,0xb8,0xd1 C popcnt %r9, %r10
88 add $2, n
89 js L(top)
90 lea (%r10, %rax), %rax
91 FUNC_EXIT()
92 ret
93
94 ALIGN(16)
95 L(top): mov (ap,n,8), %r8
96 lea (%r10, %rax), %rax
97 mov 8(ap,n,8), %r9
98 xor (bp,n,8), %r8
99 xor 8(bp,n,8), %r9
100 .byte 0xf3,0x49,0x0f,0xb8,0xc8 C popcnt %r8, %rcx
101 lea (%rcx, %rax), %rax
102 .byte 0xf3,0x4d,0x0f,0xb8,0xd1 C popcnt %r9, %r10
103 add $2, n
104 js L(top)
105
106 lea (%r10, %rax), %rax
107 FUNC_EXIT()
108 ret
109 EPILOGUE()