[BACK]Return to lshift.asm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpn / x86 / k6 / mmx

Annotation of OpenXM_contrib/gmp/mpn/x86/k6/mmx/lshift.asm, Revision 1.1.1.2

1.1       maekawa     1: dnl  AMD K6 mpn_lshift -- mpn left shift.
                      2:
1.1.1.2 ! ohara       3: dnl  Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
1.1       maekawa     4: dnl
                      5: dnl  This file is part of the GNU MP Library.
                      6: dnl
                      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 2.1 of the
                     10: dnl  License, or (at your option) any later version.
                     11: dnl
                     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.
                     16: dnl
                     17: dnl  You should have received a copy of the GNU Lesser General Public
                     18: dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
                     19: dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
                     20: dnl  Suite 330, Boston, MA 02111-1307, USA.
                     21:
                     22: include(`../config.m4')
                     23:
                     24:
1.1.1.2 ! ohara      25: C K6: 3.0 cycles/limb
        !            26:
        !            27:
1.1       maekawa    28: C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
                     29: C                       unsigned shift);
                     30: C
                     31: C The loop runs at 3 cycles/limb, limited by decoding and by having 3 mmx
                     32: C instructions.  This is despite every second fetch being unaligned.
                     33:
                     34:
                     35: defframe(PARAM_SHIFT,16)
                     36: defframe(PARAM_SIZE, 12)
                     37: defframe(PARAM_SRC,  8)
                     38: defframe(PARAM_DST,  4)
                     39:
1.1.1.2 ! ohara      40:        TEXT
1.1       maekawa    41:        ALIGN(32)
                     42:
                     43: PROLOGUE(mpn_lshift)
                     44: deflit(`FRAME',0)
                     45:
                     46:        C The 1 limb case can be done without the push %ebx, but it's then
                     47:        C still the same speed.  The push is left as a free helping hand for
                     48:        C the two_or_more code.
                     49:
                     50:        movl    PARAM_SIZE, %eax
                     51:        pushl   %ebx                    FRAME_pushl()
                     52:
                     53:        movl    PARAM_SRC, %ebx
                     54:        decl    %eax
                     55:
                     56:        movl    PARAM_SHIFT, %ecx
                     57:        jnz     L(two_or_more)
                     58:
                     59:        movl    (%ebx), %edx            C src limb
                     60:        movl    PARAM_DST, %ebx
                     61:
                     62:        shldl(  %cl, %edx, %eax)        C return value
                     63:
                     64:        shll    %cl, %edx
                     65:
                     66:        movl    %edx, (%ebx)            C dst limb
                     67:        popl    %ebx
                     68:
                     69:        ret
                     70:
                     71:
                     72:        ALIGN(16)       C avoid offset 0x1f
                     73:        nop             C avoid bad cache line crossing
                     74: L(two_or_more):
                     75:        C eax   size-1
                     76:        C ebx   src
                     77:        C ecx   shift
                     78:        C edx
                     79:
                     80:        movl    (%ebx,%eax,4), %edx     C src high limb
                     81:        negl    %ecx
                     82:
                     83:        movd    PARAM_SHIFT, %mm6
                     84:        addl    $32, %ecx               C 32-shift
                     85:
                     86:        shrl    %cl, %edx
                     87:
                     88:        movd    %ecx, %mm7
                     89:        movl    PARAM_DST, %ecx
                     90:
                     91: L(top):
                     92:        C eax   counter, size-1 to 1
                     93:        C ebx   src
                     94:        C ecx   dst
                     95:        C edx   retval
                     96:        C
                     97:        C mm0   scratch
                     98:        C mm6   shift
                     99:        C mm7   32-shift
                    100:
                    101:        movq    -4(%ebx,%eax,4), %mm0
                    102:        decl    %eax
                    103:
                    104:        psrlq   %mm7, %mm0
                    105:
                    106:        movd    %mm0, 4(%ecx,%eax,4)
                    107:        jnz     L(top)
                    108:
                    109:
                    110:        movd    (%ebx), %mm0
                    111:        popl    %ebx
                    112:
                    113:        psllq   %mm6, %mm0
                    114:        movl    %edx, %eax
                    115:
                    116:        movd    %mm0, (%ecx)
                    117:
                    118:        emms
                    119:        ret
                    120:
                    121: EPILOGUE()

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>