Debian Codegraph @

mpn/x86_64/alderlake/submul_1.asm

raw
1 dnl AMD64 mpn_submul_1 for CPUs with mulx and adx.
2
3 dnl Contributed to the GNU project by Torbjörn Granlund.
4
5 dnl Copyright 2022 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
36 C AMD K8,K9 -
37 C AMD K10 -
38 C AMD bd1 -
39 C AMD bd2 -
40 C AMD bd3 -
41 C AMD bd4 -
42 C AMD zn1 ?
43 C AMD zn2 ?
44 C AMD zn3 2.0
45 C AMD bt1 -
46 C AMD bt2 -
47 C Intel P4 -
48 C Intel CNR -
49 C Intel PNR -
50 C Intel NHM -
51 C Intel WSM -
52 C Intel SBR -
53 C Intel IBR -
54 C Intel HWL -
55 C Intel BWL ?
56 C Intel SKL ?
57 C Intel RKL 2.0
58 C Intel ALD 1.53
59 C Intel atom -
60 C Intel SLM -
61 C Intel GLM -
62 C VIA nano -
63
64 define(`rp', `%rdi') dnl rcx
65 define(`up', `%rsi') dnl rdx
66 define(`n_param', `%rdx') dnl r8
67 define(`v0_param',`%rcx') dnl r9
68
69 define(`n', `%rcx') dnl
70 define(`v0', `%rdx') dnl
71
72
73 ASM_START()
74 TEXT
75 ALIGN(16)
76 PROLOGUE(mpn_submul_1)
77 mov n_param, %rax
78 mov v0_param, v0
79 mov %rax, n
80 test $1, R8(n)
81 jz L(bx0)
82
83 L(bx1): mulx( (up), %r9, %rax)
84 test $2, R8(n)
85 stc
86 jz L(b01)
87
88 L(b11): lea 1(n), n
89 lea 16(up), up
90 lea 16(rp), rp
91 jmp L(lo3)
92
93 L(b01): lea 3(n), n
94 jmp L(lo1)
95
96 L(bx0): mulx( (up), %r9, %r8)
97 test $2, R8(n)
98 stc
99 jz L(b00)
100
101 L(b10): lea 8(up), up
102 lea 8(rp), rp
103 lea 2(n), n
104 jmp L(lo2)
105
106 L(b00): lea 24(up), up
107 lea 24(rp), rp
108 jmp L(lo0)
109
110 L(top): lea 32(up), up
111 lea 32(rp), rp
112 mulx( -24,(up), %r9, %r8)
113 adox( %rax, %r9)
114 L(lo0): not %r9
115 adcx( -24,(rp), %r9)
116 mov %r9, -24(rp)
117 mulx( -16,(up), %r9, %rax)
118 adox( %r8, %r9)
119 L(lo3): not %r9
120 adcx( -16,(rp), %r9)
121 mov %r9, -16(rp)
122 mulx( -8,(up), %r9, %r8)
123 adox( %rax, %r9)
124 L(lo2): not %r9
125 adcx( -8,(rp), %r9)
126 mov %r9, -8(rp)
127 mulx( (up), %r9, %rax)
128 adox( %r8, %r9)
129 L(lo1): not %r9
130 adcx( (rp), %r9)
131 mov %r9, (rp)
132 lea -4(n), n
133 jrcxz L(end)
134 jmp L(top)
135
136 L(end): adox( %rcx, %rax)
137 sbb $-1, %rax
138 ret
139 EPILOGUE()
140 ASM_END()