1 dnl Intel Pentium mpn_lshift
-- mpn left 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_lshift (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 s_ptr + 1 >= res_ptr
71 leal (%esi,%ebp,4),%eax
73 jnc L(special) C jump if res_ptr >= s_ptr + size
76 leal -4(%edi,%ebp,4),%edi
77 leal -4(%esi,%ebp,4),%esi
82 shldl( %cl, %edx, %eax) C compute carry limb
83 pushl %eax C push carry limb onto stack
90 movl (%edi),%eax C fetch destination cache line
93 L(oop): movl -28(%edi),%eax C fetch destination cache line
98 shldl( %cl, %eax, %ebx)
99 shldl( %cl, %edx, %eax)
105 shldl( %cl, %ebx, %edx)
106 shldl( %cl, %eax, %ebx)
112 shldl( %cl, %edx, %eax)
113 shldl( %cl, %ebx, %edx)
119 shldl( %cl, %eax, %ebx)
120 shldl( %cl, %edx, %eax)
134 shldl( %cl,%eax,%edx)
143 shll %cl,%edx C compute least significant limb
144 movl %edx,(%edi) C store it
146 popl %eax C pop carry limb
155 C We loop from least significant end of the arrays, which is only
156 C permissable if the source and destination don't overlap
, since the
157 C function is documented to work for overlapping source
and destination.
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