1 dnl AMD Athlon mpn_com -- mpn bitwise one's complement.
3 dnl Copyright 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 void mpn_com (mp_ptr dst, mp_srcptr src, mp_size_t size);
28 C The loop form below is necessary for the claimed speed. It needs to be
29 C aligned to a 16 byte boundary and only 16 bytes long. Maybe that's so it
30 C fits in a BTB entry. The adjustments to %eax and %edx avoid offsets on
31 C the movq's and achieve the necessary size.
33 C If both src and dst are 4mod8, the loop runs at 1.5 c/l. So long as one
34 C of the two is 0mod8, it runs at 1.0 c/l. On that basis dst is checked
35 C (offset by the size, as per the loop addressing) and one high limb
36 C processed separately to get alignment.
38 C The padding for the nails case is unattractive, but shouldn't cost any
39 C cycles. Explicit .byte's guarantee the desired instructions, at a point
40 C where we're probably stalled waiting for loads anyway.
44 C The combination load/pxor/store might be able to be unrolled to approach
47 defframe(PARAM_SIZE,12)
48 defframe(PARAM_SRC, 8)
49 defframe(PARAM_DST, 4)
61 leal (%edx,%ecx,4), %eax
63 ifelse(GMP_NAIL_BITS,0,,
64 ` psrld $GMP_NAIL_BITS, %mm7') C GMP_NUMB_MASK
67 movd -4(%eax,%ecx,4), %mm0 C src high limb
69 ifelse(GMP_NAIL_BITS,0,,
70 ` C padding for alignment below
71 .byte 0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00 C lea 0(%esi),%esi
72 .byte 0x8d, 0xbf, 0x00, 0x00, 0x00, 0x00 C lea 0(%edi),%edi
78 movd %mm0, -4(%edx,%ecx,4) C dst high limb
88 C offset 0x30 for no nails, or 0x40 for nails
97 movq (%eax,%ecx,4), %mm0
99 movq %mm0, (%edx,%ecx,4)
102 jnz L(done) C if size even
105 movd -4(%eax), %mm0 C src low limb
107 movd %mm0, -4(%edx) C dst low limb