1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
dnl SPARC v9 mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
dnl store difference in a third limb vector.
dnl Copyright 2001-2003, 2011 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C UltraSPARC 1&2: 4
C UltraSPARC 3: 4.5
C Compute carry-out from the most significant bits of u,v, and r, where
C r=u-v-carry_in, using logic operations.
C This code runs at 4 cycles/limb on UltraSPARC 1 and 2. It has a 4 insn
C recurrency, and the UltraSPARC 1 and 2 the IE units are 100% saturated.
C Therefore, it seems futile to try to optimize this any further...
C INPUT PARAMETERS
define(`rp',`%i0')
define(`up',`%i1')
define(`vp',`%i2')
define(`n',`%i3')
define(`u0',`%l0')
define(`u1',`%l2')
define(`u2',`%l4')
define(`u3',`%l6')
define(`v0',`%l1')
define(`v1',`%l3')
define(`v2',`%l5')
define(`v3',`%l7')
define(`cy',`%i4')
define(`fanop',`fitod %f0,%f2') dnl A quasi nop running in the FA pipe
define(`fmnop',`fmuld %f0,%f0,%f4') dnl A quasi nop running in the FM pipe
ASM_START()
REGISTER(%g2,#scratch)
REGISTER(%g3,#scratch)
PROLOGUE(mpn_sub_nc)
save %sp,-160,%sp
fitod %f0,%f0 C make sure f0 contains small, quiet number
subcc n,4,%g0
bl,pn %xcc,.Loop0
nop
b,a L(com)
EPILOGUE()
PROLOGUE(mpn_sub_n)
save %sp,-160,%sp
fitod %f0,%f0 C make sure f0 contains small, quiet number
subcc n,4,%g0
bl,pn %xcc,.Loop0
mov 0,cy
L(com):
ldx [up+0],u0
ldx [vp+0],v0
add up,32,up
ldx [up-24],u1
ldx [vp+8],v1
add vp,32,vp
ldx [up-16],u2
ldx [vp-16],v2
ldx [up-8],u3
ldx [vp-8],v3
subcc n,8,n
sub u0,v0,%g1 C main sub
sub %g1,cy,%g5 C carry sub
orn u0,v0,%g2
bl,pn %xcc,.Lend4567
fanop
b,a .Loop
.align 16
C START MAIN LOOP
.Loop: orn %g5,%g2,%g2
andn u0,v0,%g3
ldx [up+0],u0
fanop
C --
andn %g2,%g3,%g2
ldx [vp+0],v0
add up,32,up
fanop
C --
srlx %g2,63,cy
sub u1,v1,%g1
stx %g5,[rp+0]
fanop
C --
sub %g1,cy,%g5
orn u1,v1,%g2
fmnop
fanop
C --
orn %g5,%g2,%g2
andn u1,v1,%g3
ldx [up-24],u1
fanop
C --
andn %g2,%g3,%g2
ldx [vp+8],v1
add vp,32,vp
fanop
C --
srlx %g2,63,cy
sub u2,v2,%g1
stx %g5,[rp+8]
fanop
C --
sub %g1,cy,%g5
orn u2,v2,%g2
fmnop
fanop
C --
orn %g5,%g2,%g2
andn u2,v2,%g3
ldx [up-16],u2
fanop
C --
andn %g2,%g3,%g2
ldx [vp-16],v2
add rp,32,rp
fanop
C --
srlx %g2,63,cy
sub u3,v3,%g1
stx %g5,[rp-16]
fanop
C --
sub %g1,cy,%g5
orn u3,v3,%g2
fmnop
fanop
C --
orn %g5,%g2,%g2
andn u3,v3,%g3
ldx [up-8],u3
fanop
C --
andn %g2,%g3,%g2
subcc n,4,n
ldx [vp-8],v3
fanop
C --
srlx %g2,63,cy
sub u0,v0,%g1
stx %g5,[rp-8]
fanop
C --
sub %g1,cy,%g5
orn u0,v0,%g2
bge,pt %xcc,.Loop
fanop
C END MAIN LOOP
.Lend4567:
orn %g5,%g2,%g2
andn u0,v0,%g3
andn %g2,%g3,%g2
srlx %g2,63,cy
sub u1,v1,%g1
stx %g5,[rp+0]
sub %g1,cy,%g5
orn u1,v1,%g2
orn %g5,%g2,%g2
andn u1,v1,%g3
andn %g2,%g3,%g2
srlx %g2,63,cy
sub u2,v2,%g1
stx %g5,[rp+8]
sub %g1,cy,%g5
orn u2,v2,%g2
orn %g5,%g2,%g2
andn u2,v2,%g3
andn %g2,%g3,%g2
add rp,32,rp
srlx %g2,63,cy
sub u3,v3,%g1
stx %g5,[rp-16]
sub %g1,cy,%g5
orn u3,v3,%g2
orn %g5,%g2,%g2
andn u3,v3,%g3
andn %g2,%g3,%g2
srlx %g2,63,cy
stx %g5,[rp-8]
addcc n,4,n
bz,pn %xcc,.Lret
fanop
.Loop0: ldx [up],u0
add up,8,up
ldx [vp],v0
add vp,8,vp
add rp,8,rp
subcc n,1,n
sub u0,v0,%g1
orn u0,v0,%g2
sub %g1,cy,%g5
andn u0,v0,%g3
orn %g5,%g2,%g2
stx %g5,[rp-8]
andn %g2,%g3,%g2
bnz,pt %xcc,.Loop0
srlx %g2,63,cy
.Lret: mov cy,%i0
ret
restore
EPILOGUE(mpn_sub_n)
|