Annotation of OpenXM_contrib/gmp/mpn/x86/pentium4/sse2/addmul_1.asm, Revision 1.1.1.1
1.1 ohara 1: dnl Intel Pentium-4 mpn_addmul_1 -- Multiply a limb vector with a limb and add
2: dnl the result to a second limb vector.
3:
4: dnl Copyright 2001, 2002 Free Software Foundation, Inc.
5: dnl
6: dnl This file is part of the GNU MP Library.
7: dnl
8: dnl The GNU MP Library is free software; you can redistribute it and/or
9: dnl modify it under the terms of the GNU Lesser General Public License as
10: dnl published by the Free Software Foundation; either version 2.1 of the
11: dnl License, or (at your option) any later version.
12: dnl
13: dnl The GNU MP Library is distributed in the hope that it will be useful,
14: dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15: dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: dnl Lesser General Public License for more details.
17: dnl
18: dnl You should have received a copy of the GNU Lesser General Public
19: dnl License along with the GNU MP Library; see the file COPYING.LIB. If
20: dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
21: dnl Suite 330, Boston, MA 02111-1307, USA.
22:
23: include(`../config.m4')
24:
25:
26: C P4: 6 cycles/limb, unstable timing, at least on early Pentium4 silicon
27: C (stepping 10).
28:
29:
30: C mp_limb_t mpn_addmul_1 (mp_ptr dst, mp_srcptr src, mp_size_t size,
31: C mp_limb_t multiplier);
32: C mp_limb_t mpn_addmul_1c (mp_ptr dst, mp_srcptr src, mp_size_t size,
33: C mp_limb_t multiplier, mp_limb_t carry);
34: C
35: C Only the carry limb propagation is on the dependent chain, but some other
36: C Pentium4 pipeline magic brings down performance to 6 cycles/l from the
37: C ideal 4 cycles/l.
38:
39: defframe(PARAM_CARRY, 20)
40: defframe(PARAM_MULTIPLIER,16)
41: defframe(PARAM_SIZE, 12)
42: defframe(PARAM_SRC, 8)
43: defframe(PARAM_DST, 4)
44:
45: TEXT
46: ALIGN(16)
47: PROLOGUE(mpn_addmul_1c)
48: deflit(`FRAME',0)
49: movd PARAM_CARRY, %mm0
50: jmp L(start_1c)
51: EPILOGUE()
52:
53: PROLOGUE(mpn_addmul_1)
54: deflit(`FRAME',0)
55: pxor %mm0, %mm0
56: L(start_1c):
57: movl PARAM_SRC, %eax
58: movl PARAM_SIZE, %ecx
59: movl PARAM_DST, %edx
60: movd PARAM_MULTIPLIER, %mm7
61:
62: C eax src, incrementing
63: C ebx
64: C ecx loop counter, decrementing
65: C edx dst, incrementing
66: C
67: C mm0 carry, low 32-bits
68: C mm7 multiplier
69:
70: L(loop):
71: movd (%eax), %mm1 C src
72: leal 4(%eax), %eax
73: movd (%edx),%mm2 C dst
74: pmuludq %mm7, %mm1
75: paddq %mm1, %mm2 C prod
76: paddq %mm2, %mm0 C carry
77: subl $1, %ecx
78: movd %mm0, (%edx) C result
79: psrlq $32, %mm0
80: leal 4(%edx), %edx
81: jnz L(loop)
82:
83: movd %mm0, %eax
84: emms
85: ret
86:
87: EPILOGUE()
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>