1 dnl AMD K6 mpn_lshift -- mpn left shift.
3 dnl Copyright 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
8 dnl modify it under the terms of the GNU Lesser General Public License as
9 dnl published by the Free Software Foundation; either version 3 of the
10 dnl License, or (at your option) any later version.
12 dnl The GNU MP Library is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 dnl Lesser General Public License for more details.
17 dnl You should have received a copy of the GNU Lesser General Public License
18 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
20 include(`../config.m4')
26 C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
29 C The loop runs at 3 cycles/limb, limited by decoding and by having 3 mmx
30 C instructions. This is despite every second fetch being unaligned.
33 defframe(PARAM_SHIFT,16)
34 defframe(PARAM_SIZE, 12)
35 defframe(PARAM_SRC, 8)
36 defframe(PARAM_DST, 4)
44 C The 1 limb case can be done without the push %ebx, but it's then
45 C still the same speed. The push is left as a free helping hand for
46 C the two_or_more code.
49 pushl %ebx FRAME_pushl()
54 movl PARAM_SHIFT, %ecx
57 movl (%ebx), %edx C src limb
60 shldl( %cl, %edx, %eax) C return value
64 movl %edx, (%ebx) C dst limb
70 ALIGN(16) C avoid offset 0x1f
71 nop C avoid bad cache line crossing
78 movl (%ebx,%eax,4), %edx C src high limb
81 movd PARAM_SHIFT, %mm6
82 addl $32, %ecx C 32-shift
90 C eax counter, size-1 to 1
99 movq -4(%ebx,%eax,4), %mm0
104 movd %mm0, 4(%ecx,%eax,4)