1 dnl Intel Pentium-4 mpn_addlsh1_n -- mpn x+2*y.
3 dnl Copyright 2001, 2002, 2003, 2004, 2006 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')
23 C cycles/limb (approx)
24 C dst!=src1,2 dst==src1 dst==src2
25 C P4 m2: 4.5 ?7.25 ?6.75
28 C mp_limb_t mpn_addlsh1_n (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
31 C The slightly strange combination of indexing and pointer incrementing
32 C that's used seems to work best. Not sure why, but %ecx,4 with src1 and/or
35 C The dependent chain is simply the paddq of x+2*y to the previous carry,
36 C then psrlq to get the new carry. That makes 4 c/l the target speed, which
37 C is almost achieved for separate src/dst but when src==dst the write
38 C combining anomalies slow it down.
40 defframe(PARAM_SIZE, 16)
41 defframe(PARAM_SRC2, 12)
42 defframe(PARAM_SRC1, 8)
43 defframe(PARAM_DST, 4)
45 dnl re-use parameter space
46 define(SAVE_EBX,`PARAM_SRC1')
51 PROLOGUE(mpn_addlsh1_n)
58 pxor %mm0, %mm0 C initial carry
64 leal (%edx,%ecx,4), %edx C dst end
70 C ecx counter, limbs, negative
85 movd %mm0, (%edx,%ecx,4)