Debian Codegraph @

mpn/x86_64/atom/mul_1.asm

raw
1 dnl AMD64 mpn_mul_1 optimised for Intel Atom.
2
3 dnl Copyright 2003-2005, 2007, 2008, 2012, 2013 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 3.03
35 C AMD K10 3.03
36 C AMD bull 4.74
37 C AMD pile 4.56
38 C AMD steam
39 C AMD excavator
40 C AMD bobcat 5.56 6.04
41 C AMD jaguar 5.55 5.84
42 C Intel P4 13.05
43 C Intel core2 4.03
44 C Intel NHM 3.80
45 C Intel SBR 2.75
46 C Intel IBR 2.69
47 C Intel HWL 2.50
48 C Intel BWL 2.55
49 C Intel SKL 2.57
50 C Intel atom 17.3
51 C Intel SLM 14.7
52 C VIA nano
53
54 C The loop of this code is the result of running a code generation and
55 C optimisation tool suite written by David Harvey and Torbjorn Granlund.
56
57 define(`rp', `%rdi') C rcx
58 define(`up', `%rsi') C rdx
59 define(`n_param', `%rdx') C r8
60 define(`v0', `%rcx') C r9
61
62 define(`n', `%r11')
63
64 ABI_SUPPORT(DOS64)
65 ABI_SUPPORT(STD64)
66
67 ASM_START()
68 TEXT
69 ALIGN(16)
70 PROLOGUE(mpn_mul_1)
71 FUNC_ENTRY(4)
72 xor %r8, %r8
73 L(com): mov (up), %rax
74 lea -16(up,n_param,8), up
75 lea -8(rp,n_param,8), rp
76 test $1, R8(n_param)
77 jnz L(bx1)
78
79 L(bx0): mov %r8, %r9
80 test $2, R8(n_param)
81 jnz L(b10)
82
83 L(b00): mov $2, R32(n)
84 sub n_param, n
85 jmp L(lo0)
86
87 L(bx1): test $2, R8(n_param)
88 jnz L(b11)
89
90 L(b01): mov $3, R32(n)
91 sub n_param, n
92 mul v0
93 cmp $2, n
94 jnz L(lo1)
95 jmp L(cj1)
96
97 L(b11): mov $1, R32(n)
98 sub n_param, n
99 jmp L(lo3)
100
101 L(b10): xor R32(n), R32(n)
102 sub n_param, n
103 jmp L(lo2)
104
105 L(top): mul v0
106 mov %r9, -24(rp,n,8)
107 L(lo1): xor %r9d, %r9d
108 add %rax, %r8
109 mov (up,n,8), %rax
110 adc %rdx, %r9
111 mov %r8, -16(rp,n,8)
112 L(lo0): xor %r8d, %r8d
113 mul v0
114 add %rax, %r9
115 mov 8(up,n,8), %rax
116 adc %rdx, %r8
117 mov %r9, -8(rp,n,8)
118 L(lo3): xor %r9d, %r9d
119 mul v0
120 add %rax, %r8
121 mov 16(up,n,8), %rax
122 adc %rdx, %r9
123 mov %r8, (rp,n,8)
124 L(lo2): xor %r8d, %r8d
125 mul v0
126 add %rax, %r9
127 mov 24(up,n,8), %rax
128 adc %rdx, %r8
129 add $4, n
130 js L(top)
131
132 L(end): mul v0
133 mov %r9, -8(rp)
134 L(cj1): add %rax, %r8
135 mov $0, R32(%rax)
136 adc %rdx, %rax
137 mov %r8, (rp)
138 FUNC_EXIT()
139 ret
140 EPILOGUE()
141
142 PROLOGUE(mpn_mul_1c)
143 FUNC_ENTRY(4)
144 IFDOS(` mov 56(%rsp), %r8 ')
145 jmp L(com)
146 EPILOGUE()
147 ASM_END()