Debian Codegraph @

mpn/x86_64/core2/lshift.asm

raw
1 dnl x86-64 mpn_lshift 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_lshift)
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,n,8), up
78 lea 16(rp,n,8), rp
79 mov (up), %r10
80 mov -8(up), %r11
81 shld R8(cnt), %r10, %rax
82 mov -16(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,n,8), up
90 lea 8(rp,n,8), rp
91 mov 8(up), %r9
92 shld R8(cnt), %r9, %rax
93 shr $2, n
94 jz L(1)
95 mov (up), %r10
96 mov -8(up), %r11
97 jmp L(01)
98
99 L(b10): lea -24(up,n,8), up
100 lea (rp,n,8), rp
101 mov 16(up), %r8
102 mov 8(up), %r9
103 shld R8(cnt), %r8, %rax
104 shr $2, n
105 jz L(2)
106 mov (up), %r10
107 jmp L(10)
108
109 ALIGN(16)
110 L(b11): lea -32(up,n,8), up
111 lea -8(rp,n,8), rp
112 mov 24(up), %r11
113 mov 16(up), %r8
114 mov 8(up), %r9
115 shld R8(cnt), %r11, %rax
116 shr $2, n
117 jz L(end)
118
119 ALIGN(16)
120 L(top): shld R8(cnt), %r8, %r11
121 mov (up), %r10
122 mov %r11, (rp)
123 L(10): shld R8(cnt), %r9, %r8
124 mov -8(up), %r11
125 mov %r8, -8(rp)
126 L(01): shld R8(cnt), %r10, %r9
127 mov -16(up), %r8
128 mov %r9, -16(rp)
129 L(00): shld R8(cnt), %r11, %r10
130 mov -24(up), %r9
131 add $-32, up
132 mov %r10, -24(rp)
133 add $-32, rp
134 dec n
135 jnz L(top)
136
137 L(end): shld R8(cnt), %r8, %r11
138 mov %r11, (rp)
139 L(2): shld R8(cnt), %r9, %r8
140 mov %r8, -8(rp)
141 L(1): shl R8(cnt), %r9
142 mov %r9, -16(rp)
143 FUNC_EXIT()
144 ret
145 EPILOGUE()