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

« back to all changes in this revision

Viewing changes to gmp3/mpn/x86/k7/mod_34lsub1.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  AMD K7 mpn_mod_32lsub1 -- remainder modulo 2^24-1.
 
2
dnl
 
3
dnl  K7: 1.0 cycles/limb
 
4
 
 
5
dnl  Copyright 2000, 2001 Free Software Foundation, Inc.
 
6
dnl 
 
7
dnl  This file is part of the GNU MP Library.
 
8
dnl 
 
9
dnl  The GNU MP Library is free software; you can redistribute it and/or
 
10
dnl  modify it under the terms of the GNU Lesser General Public License as
 
11
dnl  published by the Free Software Foundation; either version 2.1 of the
 
12
dnl  License, or (at your option) any later version.
 
13
dnl 
 
14
dnl  The GNU MP Library is distributed in the hope that it will be useful,
 
15
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
dnl  Lesser General Public License for more details.
 
18
dnl 
 
19
dnl  You should have received a copy of the GNU Lesser General Public
 
20
dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
 
21
dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
 
22
dnl  Suite 330, Boston, MA 02111-1307, USA.
 
23
 
 
24
include(`../config.m4')
 
25
 
 
26
 
 
27
C mp_limb_t mpn_mod_34lsub1 (mp_srcptr src, mp_size_t size)
 
28
C
 
29
C The loop form below and the 64 byte code alignment seem necessary for the
 
30
C claimed speed.  This is a bit strange, since normally k7 isn't very
 
31
C sensitive to such things.  Perhaps there has to be 6 instructions in the
 
32
C first 16 bytes for the BTB entry or something.
 
33
 
 
34
defframe(PARAM_SIZE, 8)
 
35
defframe(PARAM_SRC,  4)
 
36
 
 
37
dnl  re-use parameter space
 
38
define(SAVE_EDI, `PARAM_SIZE')
 
39
 
 
40
        TEXT
 
41
        ALIGN(64)
 
42
PROLOGUE(mpn_mod_34lsub1)
 
43
deflit(`FRAME',0)
 
44
 
 
45
        movl    PARAM_SIZE, %ecx
 
46
        movl    PARAM_SRC, %edx
 
47
 
 
48
        subl    $2, %ecx
 
49
        ja      L(three_or_more)
 
50
 
 
51
        movl    (%edx), %eax
 
52
        jb      L(one)
 
53
 
 
54
        movl    4(%edx), %ecx
 
55
        movl    %eax, %edx
 
56
        shrl    $24, %eax               C src[0] low
 
57
 
 
58
        andl    $0xFFFFFF, %edx         C src[0] high
 
59
        addl    %edx, %eax
 
60
        movl    %ecx, %edx
 
61
 
 
62
        andl    $0xFFFF, %ecx
 
63
        shrl    $16, %edx               C src[1] high
 
64
        addl    %edx, %eax
 
65
 
 
66
        shll    $8, %ecx                C src[1] low
 
67
        addl    %ecx, %eax
 
68
 
 
69
L(one):
 
70
        ret
 
71
 
 
72
 
 
73
L(three_or_more):
 
74
        C eax
 
75
        C ebx
 
76
        C ecx   size-2
 
77
        C edx   src
 
78
        C esi
 
79
        C edi
 
80
        C ebp
 
81
 
 
82
        pushl   %ebx    FRAME_pushl()
 
83
        xorl    %eax, %eax
 
84
        xorl    %ebx, %ebx
 
85
 
 
86
        movl    %edi, SAVE_EDI
 
87
        pushl   %esi    FRAME_pushl()
 
88
        xorl    %esi, %esi              C and clear carry flag
 
89
 
 
90
 
 
91
        C code offset 0x40 at this point
 
92
L(top):
 
93
        C eax   acc 0mod3
 
94
        C ebx   acc 1mod3
 
95
        C ecx   counter, limbs
 
96
        C edx   src
 
97
        C esi   acc 2mod3
 
98
        C edi
 
99
        C ebp
 
100
 
 
101
        leal    24(%edx), %edx
 
102
        leal    -2(%ecx), %ecx
 
103
        adcl    -24(%edx), %eax
 
104
        adcl    -20(%edx), %ebx
 
105
        adcl    -16(%edx), %esi
 
106
 
 
107
        decl    %ecx
 
108
        jng     L(done_loop)
 
109
 
 
110
        leal    -2(%ecx), %ecx
 
111
        adcl    -12(%edx), %eax
 
112
        adcl    -8(%edx), %ebx
 
113
        adcl    -4(%edx), %esi
 
114
 
 
115
        decl    %ecx
 
116
        jg      L(top)
 
117
 
 
118
 
 
119
        leal    12(%edx), %edx
 
120
 
 
121
 
 
122
L(done_loop):
 
123
        C ecx is -2, -1 or 0 representing 0, 1 or 2 more limbs, respectively
 
124
 
 
125
        incl    %ecx
 
126
        movl    $0xFFFFFFFF, %edi
 
127
        js      L(combine)
 
128
 
 
129
        adcl    -12(%edx), %eax
 
130
        decl    %ecx
 
131
        movl    $0xFFFFFF00, %edi
 
132
        js      L(combine)
 
133
 
 
134
        adcl    -8(%edx), %ebx
 
135
        movl    $0xFFFF0000, %edi
 
136
 
 
137
 
 
138
L(combine):
 
139
        C eax   acc 0mod3
 
140
        C ebx   acc 1mod3
 
141
        C ecx
 
142
        C edx
 
143
        C esi   acc 2mod3
 
144
        C edi   mask
 
145
        C ebp
 
146
 
 
147
        sbbl    %ecx, %ecx              C carry
 
148
        movl    %eax, %edx              C 0mod3
 
149
        shrl    $24, %eax               C 0mod3 high
 
150
 
 
151
        andl    %edi, %ecx              C carry masked
 
152
        andl    $0x00FFFFFF, %edx       C 0mod3 low
 
153
        movl    %ebx, %edi              C 1mod3
 
154
 
 
155
        subl    %ecx, %eax              C apply carry
 
156
        shrl    $16, %ebx               C 1mod3 high
 
157
        andl    $0xFFFF, %edi
 
158
 
 
159
        addl    %edx, %eax              C apply 0mod3 low
 
160
        movl    %esi, %edx              C 2mod3
 
161
        shll    $8, %edi                C 1mod3 low
 
162
 
 
163
        addl    %ebx, %eax              C apply 1mod3 high
 
164
        shrl    $8, %esi                C 2mod3 high
 
165
        andl    $0xFF, %edx             C 2mod3 low
 
166
 
 
167
        addl    %edi, %eax              C apply 1mod3 low
 
168
        shll    $16, %edx               C 2mod3 low
 
169
 
 
170
        addl    %esi, %eax              C apply 2mod3 high
 
171
        popl    %esi    FRAME_popl()
 
172
 
 
173
        movl    SAVE_EDI, %edi
 
174
        addl    %edx, %eax              C apply 2mod3 low
 
175
        popl    %ebx    FRAME_popl()
 
176
 
 
177
        ret
 
178
 
 
179
EPILOGUE()