Debian Codegraph @

mpn/x86_64/coreisbr/mul_2.asm

raw
1 dnl AMD64 mpn_mul_2 optimised for Intel Sandy Bridge.
2
3 dnl Contributed to the GNU project by Torbjörn Granlund.
4
5 dnl Copyright 2003-2005, 2007, 2008, 2011-2013 Free Software Foundation, Inc.
6
7 dnl This file is part of the GNU MP Library.
8 dnl
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of either:
11 dnl
12 dnl * the GNU Lesser General Public License as published by the Free
13 dnl Software Foundation; either version 3 of the License, or (at your
14 dnl option) any later version.
15 dnl
16 dnl or
17 dnl
18 dnl * the GNU General Public License as published by the Free Software
19 dnl Foundation; either version 2 of the License, or (at your option) any
20 dnl later version.
21 dnl
22 dnl or both in parallel, as here.
23 dnl
24 dnl The GNU MP Library is distributed in the hope that it will be useful, but
25 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 dnl for more details.
28 dnl
29 dnl You should have received copies of the GNU General Public License and the
30 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
31 dnl see https://www.gnu.org/licenses/.
32
33 include(`../config.m4')
34
35 C cycles/limb best
36 C AMD K8,K9 8.03
37 C AMD K10 8.03
38 C AMD bull 9.19
39 C AMD pile 9.16
40 C AMD steam
41 C AMD excavator
42 C AMD bobcat 10.6
43 C AMD jaguar 11.0
44 C Intel P4 26.0
45 C Intel core2 8.73
46 C Intel NHM 8.55
47 C Intel SBR 5.15
48 C Intel IBR 4.57
49 C Intel HWL 4.08
50 C Intel BWL 4.10
51 C Intel SKL 4.14
52 C Intel atom 39.5
53 C Intel SLM 26.3
54 C VIA nano
55
56 C This code is the result of running a code generation and optimisation tool
57 C suite written by David Harvey and Torbjorn Granlund.
58
59 C When playing with pointers, set this to $2 to fall back to conservative
60 C indexing in wind-down code.
61 define(`I',`$1')
62
63 define(`rp', `%rdi') C rcx
64 define(`up', `%rsi') C rdx
65 define(`n_param', `%rdx') C r8
66 define(`vp', `%rcx') C r9
67
68 define(`n', `%rcx')
69 define(`v0', `%rbx')
70 define(`v1', `%rbp')
71
72 define(`w0', `%r8')
73 define(`w1', `%r9')
74 define(`w2', `%r10')
75 define(`w3', `%r11')
76
77 ABI_SUPPORT(DOS64)
78 ABI_SUPPORT(STD64)
79
80 ASM_START()
81 TEXT
82 ALIGN(32)
83 PROLOGUE(mpn_mul_2)
84 FUNC_ENTRY(4)
85 push %rbx
86 push %rbp
87
88 mov (vp), v0
89 mov 8(vp), v1
90
91 mov (up), %rax
92 lea (up,n_param,8), up
93 lea (rp,n_param,8), rp
94
95 test $1, R8(n_param)
96 jnz L(b1)
97
98 L(b0): mov $0, R32(n)
99 sub n_param, n
100 xor w0, w0
101 mul v0
102 mov %rax, w2
103 mov %rdx, w1
104 mov (up,n,8), %rax
105 jmp L(lo0)
106
107 L(b1): mov $1, R32(n)
108 sub n_param, n
109 xor w2, w2
110 mul v0
111 mov %rax, w0
112 mov %rdx, w3
113 mov -8(up,n,8), %rax
114 mul v1
115 jmp L(lo1)
116
117 ALIGN(32)
118 L(top): mul v0
119 add %rax, w0 C 1
120 mov %rdx, w3 C 2
121 adc $0, w3 C 2
122 mov -8(up,n,8), %rax
123 mul v1
124 add w1, w0 C 1
125 adc $0, w3 C 2
126 L(lo1): add %rax, w2 C 2
127 mov w0, -8(rp,n,8) C 1
128 mov %rdx, w0 C 3
129 adc $0, w0 C 3
130 mov (up,n,8), %rax
131 mul v0
132 add %rax, w2 C 2
133 mov %rdx, w1 C 3
134 adc $0, w1 C 3
135 add w3, w2 C 2
136 mov (up,n,8), %rax
137 adc $0, w1 C 1
138 L(lo0): mul v1
139 mov w2, (rp,n,8) C 2
140 add %rax, w0 C 3
141 mov %rdx, w2 C 4
142 mov 8(up,n,8), %rax
143 adc $0, w2 C 4
144 add $2, n
145 jnc L(top)
146
147 L(end): mul v0
148 add %rax, w0
149 mov %rdx, w3
150 adc $0, w3
151 mov I(-8(up),-8(up,n,8)), %rax
152 mul v1
153 add w1, w0
154 adc $0, w3
155 add %rax, w2
156 mov w0, I(-8(rp),-8(rp,n,8))
157 adc $0, %rdx
158 add w3, w2
159 mov w2, I((rp),(rp,n,8))
160 adc $0, %rdx
161 mov %rdx, %rax
162
163 pop %rbp
164 pop %rbx
165 FUNC_EXIT()
166 ret
167 EPILOGUE()