aboutsummaryrefslogtreecommitdiff
path: root/vendor/gmp-6.3.0/mpn/alpha/bdiv_dbm1c.asm
blob: 472966ca98e4159170edf3dabb915bc4e172a425 (plain) (blame)
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
dnl  Alpha mpn_bdiv_dbm1c.

dnl  Copyright 2008 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 EV4:     42
C EV5:     18
C EV6:      3

C TODO
C  * Try less unrolling, 2-way should give the same performance.
C  * Optimize feed-in and wind-down code, for speed, and perhaps further for
C    code size.
C  * This runs optimally given the algorithm, r8 is on a 3 operation recurrency
C    path.  We have not tried very hard to find a better algorithm.  Perhaps
C    it would be a good task for the GNU superoptimizer.

C INPUT PARAMETERS
define(`rp', `r16')
define(`up', `r17')
define(`n',  `r18')
define(`bd', `r19')
define(`cy', `r19')


ASM_START()
PROLOGUE(mpn_bdiv_dbm1c)
	mov	r20, r8

	ldq	r24, 0(r17)
	and	r18, 3, r28
	lda	r18, -4(r18)
	beq	r28, L(b0)
	cmpeq	r28, 1, r21
	bne	r21, L(b1)
	cmpeq	r28, 2, r21
	bne	r21, L(b2)


L(b3):	ldq	r2, 8(r17)
	ldq	r3, 16(r17)
	bgt	r18, L(gt3)

	mulq	r24, r19, r5	C U1
	umulh	r24, r19, r21	C U1
	mulq	r2, r19, r6	C U1
	umulh	r2, r19, r22	C U1
	mulq	r3, r19, r7	C U1
	umulh	r3, r19, r23	C U1
	lda	r16, -32(r16)
	br	L(cj3)

L(gt3):	ldq	r0, 24(r17)
	mulq	r24, r19, r5	C U1
	umulh	r24, r19, r21	C U1
	ldq	r1, 32(r17)
	mulq	r2, r19, r6	C U1
	umulh	r2, r19, r22	C U1
	ldq	r2, 40(r17)
	mulq	r3, r19, r7	C U1
	umulh	r3, r19, r23	C U1
	ldq	r3, 48(r17)
	lda	r18, -4(r18)
	lda	r17, 56(r17)
	mulq	r0, r19, r4	C U1
	bgt	r18, L(L3)

	br	L(cj7)


L(b2):	ldq	r3, 8(r17)
	bgt	r18, L(gt2)

	mulq	r24, r19, r6	C U1
	umulh	r24, r19, r22	C U1
	mulq	r3, r19, r7	C U1
	umulh	r3, r19, r23	C U1
	lda	r16, -40(r16)
	br	L(cj2)

L(gt2):	ldq	r0, 16(r17)
	ldq	r1, 24(r17)
	mulq	r24, r19, r6	C U1
	umulh	r24, r19, r22	C U1
	ldq	r2, 32(r17)
	mulq	r3, r19, r7	C U1
	umulh	r3, r19, r23	C U1
	ldq	r3, 40(r17)
	lda	r18, -4(r18)
	lda	r17, 48(r17)
	mulq	r0, r19, r4	C U1
	umulh	r0, r19, r20	C U1
	lda	r16, -8(r16)
	bgt	r18, L(gt6)

	mulq	r1, r19, r5	C U1
	br	L(cj6)

L(gt6):	ldq	r0, 0(r17)
	mulq	r1, r19, r5	C U1
	br	L(L2)


L(b1):	bgt	r18, L(gt1)

	mulq	r24, r19, r7	C U1
	umulh	r24, r19, r23	C U1
	lda	r16, -48(r16)
	br	L(cj1)

L(gt1):	ldq	r0, 8(r17)
	ldq	r1, 16(r17)
	ldq	r2, 24(r17)
	mulq	r24, r19, r7	C U1
	umulh	r24, r19, r23	C U1
	ldq	r3, 32(r17)
	lda	r18, -4(r18)
	lda	r17, 40(r17)
	mulq	r0, r19, r4	C U1
	umulh	r0, r19, r20	C U1
	lda	r16, -16(r16)
	bgt	r18, L(gt5)

	mulq	r1, r19, r5	C U1
	umulh	r1, r19, r21	C U1
	mulq	r2, r19, r6	C U1
	br	L(cj5)

L(gt5):	ldq	r0, 0(r17)
	mulq	r1, r19, r5	C U1
	umulh	r1, r19, r21	C U1
	ldq	r1, 8(r17)
	mulq	r2, r19, r6	C U1
	br	L(L1)


L(b0):	ldq	r1, 8(r17)
	ldq	r2, 16(r17)
	ldq	r3, 24(r17)
	lda	r17, 32(r17)
	lda	r16, -24(r16)
	mulq	r24, r19, r4	C U1
	umulh	r24, r19, r20	C U1
	bgt	r18, L(gt4)

	mulq	r1, r19, r5	C U1
	umulh	r1, r19, r21	C U1
	mulq	r2, r19, r6	C U1
	umulh	r2, r19, r22	C U1
	mulq	r3, r19, r7	C U1
	br	L(cj4)

L(gt4):	ldq	r0, 0(r17)
	mulq	r1, r19, r5	C U1
	umulh	r1, r19, r21	C U1
	ldq	r1, 8(r17)
	mulq	r2, r19, r6	C U1
	umulh	r2, r19, r22	C U1
	ldq	r2, 16(r17)
	mulq	r3, r19, r7	C U1
	br	L(L0)

C *** MAIN LOOP START ***
	ALIGN(16)
L(top):	mulq	r0, r19, r4	C U1
	subq	r8, r28, r8
L(L3):	umulh	r0, r19, r20	C U1
	cmpult	r8, r5, r28
	ldq	r0, 0(r17)
	subq	r8, r5, r8
	addq	r21, r28, r28
	stq	r8, 0(r16)

	mulq	r1, r19, r5	C U1
	subq	r8, r28, r8
L(L2):	umulh	r1, r19, r21	C U1
	cmpult	r8, r6, r28
	ldq	r1, 8(r17)
	subq	r8, r6, r8
	addq	r22, r28, r28
	stq	r8, 8(r16)

	mulq	r2, r19, r6	C U1
	subq	r8, r28, r8
L(L1):	umulh	r2, r19, r22	C U1
	cmpult	r8, r7, r28
	ldq	r2, 16(r17)
	subq	r8, r7, r8
	addq	r23, r28, r28
	stq	r8, 16(r16)

	mulq	r3, r19, r7	C U1
	subq	r8, r28, r8
L(L0):	umulh	r3, r19, r23	C U1
	cmpult	r8, r4, r28
	ldq	r3, 24(r17)
	subq	r8, r4, r8
	addq	r20, r28, r28
	stq	r8, 24(r16)

	lda	r18, -4(r18)
	lda	r17, 32(r17)
	lda	r16, 32(r16)
	bgt	r18, L(top)
C *** MAIN LOOP END ***

	mulq	r0, r19, r4	C U1
	subq	r8, r28, r8
L(cj7):	umulh	r0, r19, r20	C U1
	cmpult	r8, r5, r28
	subq	r8, r5, r8
	addq	r21, r28, r28
	stq	r8, 0(r16)
	mulq	r1, r19, r5	C U1
	subq	r8, r28, r8
L(cj6):	umulh	r1, r19, r21	C U1
	cmpult	r8, r6, r28
	subq	r8, r6, r8
	addq	r22, r28, r28
	stq	r8, 8(r16)
	mulq	r2, r19, r6	C U1
	subq	r8, r28, r8
L(cj5):	umulh	r2, r19, r22	C U1
	cmpult	r8, r7, r28
	subq	r8, r7, r8
	addq	r23, r28, r28
	stq	r8, 16(r16)
	mulq	r3, r19, r7	C U1
	subq	r8, r28, r8
L(cj4):	umulh	r3, r19, r23	C U1
	cmpult	r8, r4, r28
	subq	r8, r4, r8
	addq	r20, r28, r28
	stq	r8, 24(r16)
	subq	r8, r28, r8
L(cj3):	cmpult	r8, r5, r28
	subq	r8, r5, r8
	addq	r21, r28, r28
	stq	r8, 32(r16)
	subq	r8, r28, r8
L(cj2):	cmpult	r8, r6, r28
	subq	r8, r6, r8
	addq	r22, r28, r28
	stq	r8, 40(r16)
	subq	r8, r28, r8
L(cj1):	cmpult	r8, r7, r28
	subq	r8, r7, r8
	addq	r23, r28, r28
	stq	r8, 48(r16)
	subq	r8, r28, r0
	ret	r31, (r26), 1

EPILOGUE()
ASM_END()