~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to gmp3/mpn/x86/pentium4/sse2/addmul_1.asm

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
dnl 
 
4
dnl  Pentium4: 6 cycles/limb, unstable timing, at least on early Pentium4
 
5
dnl  silicon (stepping 10).
 
6
 
 
7
dnl  Copyright 2001 Free Software Foundation, Inc.
 
8
dnl 
 
9
dnl  This file is part of the GNU MP Library.
 
10
dnl 
 
11
dnl  The GNU MP Library is free software; you can redistribute it and/or
 
12
dnl  modify it under the terms of the GNU Lesser General Public License as
 
13
dnl  published by the Free Software Foundation; either version 2.1 of the
 
14
dnl  License, or (at your option) any later version.
 
15
dnl 
 
16
dnl  The GNU MP Library is distributed in the hope that it will be useful,
 
17
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
dnl  Lesser General Public License for more details.
 
20
dnl 
 
21
dnl  You should have received a copy of the GNU Lesser General Public
 
22
dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
 
23
dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
 
24
dnl  Suite 330, Boston, MA 02111-1307, USA.
 
25
 
 
26
 
 
27
include(`../config.m4')
 
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     LF(mpn_addmul_1,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()