1 dnl Intel Pentium mpn_lshift -- mpn left shift.
8 dnl Copyright (C) 1992, 1994, 1995, 1996, 1999, 2000 Free Software
11 dnl This file is part of the GNU MP Library.
13 dnl The GNU MP Library is free software; you can redistribute it and/or
14 dnl modify it under the terms of the GNU Lesser General Public License as
15 dnl published by the Free Software Foundation; either version 2.1 of the
16 dnl License, or (at your option) any later version.
18 dnl The GNU MP Library is distributed in the hope that it will be useful,
19 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
20 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 dnl Lesser General Public License for more details.
23 dnl You should have received a copy of the GNU Lesser General Public
24 dnl License along with the GNU MP Library; see the file COPYING.LIB. If
25 dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
26 dnl Suite 330, Boston, MA 02111-1307, USA.
29 include(`../config.m4')
32 C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
35 C The main shift-by-N loop should run at 5.375 c/l and that's what P55 does,
36 C but P5 and P54 run only at 6.0 c/l, which is 4 cycles lost somewhere.
38 defframe(PARAM_SHIFT,16)
39 defframe(PARAM_SIZE, 12)
40 defframe(PARAM_SRC, 8)
41 defframe(PARAM_DST, 4)
58 C We can use faster code for shift-by-1 under certain conditions.
63 jnc L(special) C jump if s_ptr + 1 >= res_ptr
64 leal (%esi,%ebp,4),%eax
66 jnc L(special) C jump if res_ptr >= s_ptr + size
69 leal -4(%edi,%ebp,4),%edi
70 leal -4(%esi,%ebp,4),%esi
75 shldl( %cl, %edx, %eax) C compute carry limb
76 pushl %eax C push carry limb onto stack
83 movl (%edi),%eax C fetch destination cache line
86 L(oop): movl -28(%edi),%eax C fetch destination cache line
91 shldl( %cl, %eax, %ebx)
92 shldl( %cl, %edx, %eax)
98 shldl( %cl, %ebx, %edx)
99 shldl( %cl, %eax, %ebx)
105 shldl( %cl, %edx, %eax)
106 shldl( %cl, %ebx, %edx)
112 shldl( %cl, %eax, %ebx)
113 shldl( %cl, %edx, %eax)
127 shldl( %cl,%eax,%edx)
136 shll %cl,%edx C compute least significant limb
137 movl %edx,(%edi) C store it
139 popl %eax C pop carry limb
148 C We loop from least significant end of the arrays, which is only
149 C permissable if the source and destination don't overlap, since the
150 C function is documented to work for overlapping source and destination.
165 movl (%edi),%eax C fetch destination cache line
169 movl 28(%edi),%eax C fetch destination cache line
200 leal 32(%esi),%esi C use leal not to clobber carry
207 sbbl %eax,%eax C save carry in %eax
210 addl %eax,%eax C restore carry from eax
217 leal 4(%esi),%esi C use leal not to clobber carry
224 addl %eax,%eax C restore carry from eax
225 L(L1): movl %edx,(%edi) C store last limb