1 dnl AMD K6 mpn_rshift -- mpn right 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_rshift (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)
45 C The 1 limb case can be done without the push %ebx, but it's then
46 C still the same speed. The push is left as a free helping hand for
47 C the two_or_more code.
50 pushl %ebx FRAME_pushl()
55 movl PARAM_SHIFT, %ecx
58 movl (%ebx), %edx C src limb
61 shrdl( %cl, %edx, %eax) C return value
65 movl %edx, (%ebx) C dst limb
71 ALIGN(16) C avoid offset 0x1f
78 movl (%ebx), %edx C src low limb
81 addl $32, %ecx C 32-shift
82 movd PARAM_SHIFT, %mm6
84 shll %cl, %edx C retval
87 leal (%ebx,%eax,4), %ebx
89 leal -4(%ecx,%eax,4), %ecx
94 C eax counter (negative)
102 Zdisp( movq, 0,(%ebx,%eax,4), %mm0)
107 Zdisp( movd, %mm0, 0,(%ecx,%eax,4))