1 dnl Intel Pentium mpn_rshift
-- mpn right shift.
3 dnl Copyright
1992, 1994-1996, 1999, 2000, 2002 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
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.
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
20 dnl
or both
in parallel
, as here.
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
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
')
39 C mp_limb_t mpn_rshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
42 C The main shift-by-N loop should run at 5.375 c/l and that's what P55 does
,
43 C but P5
and P54 run only at
6.0 c
/l
, which is
4 cycles lost somewhere.
45 defframe
(PARAM_SHIFT
,16)
46 defframe
(PARAM_SIZE
, 12)
47 defframe
(PARAM_SRC
, 8)
48 defframe
(PARAM_DST
, 4)
65 C We can use faster code for shift-by-1 under certain conditions.
70 jnc L(special) C jump if res_ptr + 1 >= s_ptr
71 leal (%edi,%ebp,4),%eax
73 jnc L(special) C jump if s_ptr >= res_ptr + size
79 shrdl( %cl, %edx, %eax) C compute carry limb
80 pushl %eax C push carry limb onto stack
87 movl (%edi),%eax C fetch destination cache line
90 L(oop): movl 28(%edi),%eax C fetch destination cache line
95 shrdl( %cl, %eax, %ebx)
96 shrdl( %cl, %edx, %eax)
102 shrdl( %cl, %ebx, %edx)
103 shrdl( %cl, %eax, %ebx)
109 shrdl( %cl, %edx, %eax)
110 shrdl( %cl, %ebx, %edx)
116 shrdl( %cl, %eax, %ebx)
117 shrdl( %cl, %edx, %eax)
131 shrdl( %cl,%eax,%edx) C compute result limb
140 shrl %cl,%edx C compute most significant limb
141 movl %edx,(%edi) C store it
143 popl %eax C pop carry limb
152 C We loop from least significant end of the arrays, which is only
153 C permissable if the source and destination don't overlap
, since the
154 C function is documented to work for overlapping source
and destination.
157 leal
-4(%edi,%ebp,4),%edi
158 leal
-4(%esi,%ebp,4),%esi
172 movl
(%edi),%eax C fetch destination cache line
176 movl
-28(%edi),%eax C fetch destination cache line
207 leal
-32(%esi),%esi C use leal
not to clobber carry
214 sbbl
%eax,%eax C save carry
in %eax
217 addl
%eax,%eax C restore carry from
eax
224 leal
-4(%esi),%esi C use leal
not to clobber carry
231 addl
%eax,%eax C restore carry from
eax
232 L
(L1
): movl
%edx,(%edi) C store last limb