Debian Codegraph @

mpn/x86_64/core2/rshift.asm

raw
1 dnl x86-64 mpn_rshift optimised for Conroe/Penryn and Nehalem.
2
3 dnl Copyright 2007, 2009, 2011, 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
36 C AMD bd1
37 C AMD bd2
38 C AMD bd3
39 C AMD bd4
40 C AMD zen
41 C AMD bobcat
42 C AMD jaguar
43 C Intel P4
44 C Intel core2 1.32
45 C Intel NHM 1.30 (drops to 2.5 for n > 256)
46 C Intel SBR
47 C Intel IBR
48 C Intel HWL
49 C Intel BWL
50 C Intel SKL
51 C Intel atom
52 C Intel SLM
53 C VIA nano
54
55 C INPUT PARAMETERS
56 define(`rp', `%rdi')
57 define(`up', `%rsi')
58 define(`n', `%rdx')
59 define(`cnt', `%rcx')
60
61 ABI_SUPPORT(DOS64)
62 ABI_SUPPORT(STD64)
63
64 ASM_START()
65 TEXT
66 ALIGN(16)
67 PROLOGUE(mpn_rshift)
68 FUNC_ENTRY(4)
69
70 xor R32(%rax), R32(%rax)
71
72 test $1, R8(n)
73 jnz L(bx1)
74 L(bx0): test $2, R8(n)
75 jnz L(b10)
76
77 L(b00): lea 8(up), up
78 lea -24(rp), rp
79 mov -8(up), %r10
80 mov (up), %r11
81 shrd R8(cnt), %r10, %rax
82 mov 8(up), %r8
83 shr $2, n
84 jmp L(00)
85
86 L(bx1): test $2, R8(n)
87 jnz L(b11)
88
89 L(b01): lea 16(up), up
90 lea -16(rp), rp
91 mov -16(up), %r9
92 shrd R8(cnt), %r9, %rax
93 shr $2, n
94 jz L(1)
95 mov -8(up), %r10
96 mov (up), %r11
97 jmp L(01)
98
99 L(b10): lea 24(up), up
100 lea -8(rp), rp
101 mov -24(up), %r8
102 mov -16(up), %r9
103 shrd R8(cnt), %r8, %rax
104 shr $2, n
105 jz L(2)
106 mov -8(up), %r10
107 jmp L(10)
108
109 L(b11): lea 32(up), up
110 mov -32(up), %r11
111 mov -24(up), %r8
112 mov -16(up), %r9
113 shrd R8(cnt), %r11, %rax
114 shr $2, n
115 jz L(end)
116
117 ALIGN(16)
118 L(top): shrd R8(cnt), %r8, %r11
119 mov -8(up), %r10
120 mov %r11, (rp)
121 L(10): shrd R8(cnt), %r9, %r8
122 mov (up), %r11
123 mov %r8, 8(rp)
124 L(01): shrd R8(cnt), %r10, %r9
125 mov 8(up), %r8
126 mov %r9, 16(rp)
127 L(00): shrd R8(cnt), %r11, %r10
128 mov 16(up), %r9
129 add $32, up
130 mov %r10, 24(rp)
131 add $32, rp
132 dec n
133 jnz L(top)
134
135 L(end): shrd R8(cnt), %r8, %r11
136 mov %r11, (rp)
137 L(2): shrd R8(cnt), %r9, %r8
138 mov %r8, 8(rp)
139 L(1): shr R8(cnt), %r9
140 mov %r9, 16(rp)
141 FUNC_EXIT()
142 ret
143 EPILOGUE()