Debian Codegraph @

mpn/x86_64/core2/lshiftc.asm

raw
1 dnl x86-64 mpn_lshiftc 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.52
45 C Intel NHM 1.78 (just 2.15 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 C TODO
62 C * This runs poorly on Nehalem compared to plain lshift, in particular for
63 C n < 256.
64
65 ABI_SUPPORT(DOS64)
66 ABI_SUPPORT(STD64)
67
68 ASM_START()
69 TEXT
70 ALIGN(16)
71 PROLOGUE(mpn_lshiftc)
72 FUNC_ENTRY(4)
73
74 xor R32(%rax), R32(%rax)
75
76 test $1, R8(n)
77 jnz L(bx1)
78 L(bx0): test $2, R8(n)
79 jnz L(b10)
80
81 L(b00): lea -8(up,n,8), up
82 lea 16(rp,n,8), rp
83 mov (up), %r10
84 mov -8(up), %r11
85 shld R8(cnt), %r10, %rax
86 mov -16(up), %r8
87 shr $2, n
88 shld R8(cnt), %r11, %r10
89 jmp L(00)
90
91 L(bx1): test $2, R8(n)
92 jnz L(b11)
93
94 L(b01): lea -16(up,n,8), up
95 lea 8(rp,n,8), rp
96 mov 8(up), %r9
97 shld R8(cnt), %r9, %rax
98 shr $2, n
99 jz L(1)
100 mov (up), %r10
101 mov -8(up), %r11
102 shld R8(cnt), %r10, %r9
103 jmp L(01)
104
105 L(b10): lea -24(up,n,8), up
106 lea (rp,n,8), rp
107 mov 16(up), %r8
108 mov 8(up), %r9
109 shld R8(cnt), %r8, %rax
110 shr $2, n
111 jz L(2)
112 mov (up), %r10
113 shld R8(cnt), %r9, %r8
114 jmp L(10)
115
116 ALIGN(16)
117 L(b11): lea -32(up,n,8), up
118 lea -8(rp,n,8), rp
119 mov 24(up), %r11
120 mov 16(up), %r8
121 mov 8(up), %r9
122 shld R8(cnt), %r11, %rax
123 shr $2, n
124 jz L(end)
125
126 ALIGN(16)
127 L(top): shld R8(cnt), %r8, %r11
128 mov (up), %r10
129 not %r11
130 shld R8(cnt), %r9, %r8
131 mov %r11, (rp)
132 L(10): mov -8(up), %r11
133 not %r8
134 shld R8(cnt), %r10, %r9
135 mov %r8, -8(rp)
136 L(01): mov -16(up), %r8
137 not %r9
138 shld R8(cnt), %r11, %r10
139 mov %r9, -16(rp)
140 L(00): mov -24(up), %r9
141 not %r10
142 add $-32, up
143 mov %r10, -24(rp)
144 add $-32, rp
145 dec n
146 jnz L(top)
147
148 L(end): shld R8(cnt), %r8, %r11
149 not %r11
150 mov %r11, (rp)
151 L(2): shld R8(cnt), %r9, %r8
152 not %r8
153 mov %r8, -8(rp)
154 L(1): shl R8(cnt), %r9
155 not %r9
156 mov %r9, -16(rp)
157 FUNC_EXIT()
158 ret
159 EPILOGUE()