beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / x86_64 / core2 / rshift.asm
blobab32ec85dffc122ac306a0275831a8c90cbeb621
1 dnl x86-64 mpn_rshift optimized for "Core 2".
3 dnl Copyright 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
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/.
31 include(`../config.m4')
34 C cycles/limb
35 C AMD K8,K9 4.25
36 C AMD K10 4.25
37 C Intel P4 14.7
38 C Intel core2 1.27
39 C Intel NHM 1.375 (up to about n = 260, then 1.5)
40 C Intel SBR 1.77
41 C Intel atom ?
42 C VIA nano ?
45 C INPUT PARAMETERS
46 define(`rp', `%rdi')
47 define(`up', `%rsi')
48 define(`n', `%rdx')
49 define(`cnt', `%rcx')
51 ABI_SUPPORT(DOS64)
52 ABI_SUPPORT(STD64)
54 ASM_START()
55 TEXT
56 ALIGN(16)
57 PROLOGUE(mpn_rshift)
58 FUNC_ENTRY(4)
59 mov R32(%rdx), R32(%rax)
60 and $3, R32(%rax)
61 jne L(nb00)
62 L(b00): C n = 4, 8, 12, ...
63 mov (up), %r10
64 mov 8(up), %r11
65 xor R32(%rax), R32(%rax)
66 shrd R8(cnt), %r10, %rax
67 mov 16(up), %r8
68 lea 8(up), up
69 lea -24(rp), rp
70 sub $4, n
71 jmp L(00)
73 L(nb00):C n = 1, 5, 9, ...
74 cmp $2, R32(%rax)
75 jae L(nb01)
76 L(b01): mov (up), %r9
77 xor R32(%rax), R32(%rax)
78 shrd R8(cnt), %r9, %rax
79 sub $2, n
80 jb L(le1)
81 mov 8(up), %r10
82 mov 16(up), %r11
83 lea 16(up), up
84 lea -16(rp), rp
85 jmp L(01)
86 L(le1): shr R8(cnt), %r9
87 mov %r9, (rp)
88 FUNC_EXIT()
89 ret
91 L(nb01):C n = 2, 6, 10, ...
92 jne L(b11)
93 L(b10): mov (up), %r8
94 mov 8(up), %r9
95 xor R32(%rax), R32(%rax)
96 shrd R8(cnt), %r8, %rax
97 sub $3, n
98 jb L(le2)
99 mov 16(up), %r10
100 lea 24(up), up
101 lea -8(rp), rp
102 jmp L(10)
103 L(le2): shrd R8(cnt), %r9, %r8
104 mov %r8, (rp)
105 shr R8(cnt), %r9
106 mov %r9, 8(rp)
107 FUNC_EXIT()
110 ALIGN(16)
111 L(b11): C n = 3, 7, 11, ...
112 mov (up), %r11
113 mov 8(up), %r8
114 xor R32(%rax), R32(%rax)
115 shrd R8(cnt), %r11, %rax
116 mov 16(up), %r9
117 lea 32(up), up
118 sub $4, n
119 jb L(end)
121 ALIGN(16)
122 L(top): shrd R8(cnt), %r8, %r11
123 mov -8(up), %r10
124 mov %r11, (rp)
125 L(10): shrd R8(cnt), %r9, %r8
126 mov (up), %r11
127 mov %r8, 8(rp)
128 L(01): shrd R8(cnt), %r10, %r9
129 mov 8(up), %r8
130 mov %r9, 16(rp)
131 L(00): shrd R8(cnt), %r11, %r10
132 mov 16(up), %r9
133 mov %r10, 24(rp)
134 add $32, up
135 lea 32(rp), rp
136 sub $4, n
137 jnc L(top)
139 L(end): shrd R8(cnt), %r8, %r11
140 mov %r11, (rp)
141 shrd R8(cnt), %r9, %r8
142 mov %r8, 8(rp)
143 shr R8(cnt), %r9
144 mov %r9, 16(rp)
145 FUNC_EXIT()
147 EPILOGUE()