1 dnl Intel Pentium mpn_lshift -- mpn left shift.
3 dnl Copyright 1992, 1994, 1995, 1996, 1999, 2000, 2002 Free Software
6 dnl This file is part of the GNU MP Library.
8 dnl The GNU MP Library is free software; you can redistribute it and/or
9 dnl modify it under the terms of the GNU Lesser General Public License as
10 dnl published by the Free Software Foundation; either version 3 of the
11 dnl License, or (at your option) any later version.
13 dnl The GNU MP Library is distributed in the hope that it will be useful,
14 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 dnl Lesser General Public License for more details.
18 dnl You should have received a copy of the GNU Lesser General Public License
19 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
21 include(`../config.m4')
29 C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
32 C The main shift-by-N loop should run at 5.375 c/l and that's what P55 does,
33 C but P5 and P54 run only at 6.0 c/l, which is 4 cycles lost somewhere.
35 defframe(PARAM_SHIFT,16)
36 defframe(PARAM_SIZE, 12)
37 defframe(PARAM_SRC, 8)
38 defframe(PARAM_DST, 4)
55 C We can use faster code for shift-by-1 under certain conditions.
60 jnc L(special) C jump if s_ptr + 1 >= res_ptr
61 leal (%esi,%ebp,4),%eax
63 jnc L(special) C jump if res_ptr >= s_ptr + size
66 leal -4(%edi,%ebp,4),%edi
67 leal -4(%esi,%ebp,4),%esi
72 shldl( %cl, %edx, %eax) C compute carry limb
73 pushl %eax C push carry limb onto stack
80 movl (%edi),%eax C fetch destination cache line
83 L(oop): movl -28(%edi),%eax C fetch destination cache line
88 shldl( %cl, %eax, %ebx)
89 shldl( %cl, %edx, %eax)
95 shldl( %cl, %ebx, %edx)
96 shldl( %cl, %eax, %ebx)
102 shldl( %cl, %edx, %eax)
103 shldl( %cl, %ebx, %edx)
109 shldl( %cl, %eax, %ebx)
110 shldl( %cl, %edx, %eax)
124 shldl( %cl,%eax,%edx)
133 shll %cl,%edx C compute least significant limb
134 movl %edx,(%edi) C store it
136 popl %eax C pop carry limb
145 C We loop from least significant end of the arrays, which is only
146 C permissable if the source and destination don't overlap, since the
147 C function is documented to work for overlapping source and destination.
162 movl (%edi),%eax C fetch destination cache line
166 movl 28(%edi),%eax C fetch destination cache line
197 leal 32(%esi),%esi C use leal not to clobber carry
204 sbbl %eax,%eax C save carry in %eax
207 addl %eax,%eax C restore carry from eax
214 leal 4(%esi),%esi C use leal not to clobber carry
221 addl %eax,%eax C restore carry from eax
222 L(L1): movl %edx,(%edi) C store last limb