1 dnl IA
-64 mpn_mod_34lsub1
3 dnl Contributed to the GNU project by Torbjorn Granlund.
5 dnl Copyright
2003-2005, 2010 Free Software Foundation
, Inc.
7 dnl
This file is part of the GNU MP Library.
9 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
10 dnl it under the terms of
either:
12 dnl
* the GNU Lesser General
Public License as published by the Free
13 dnl Software Foundation
; either version 3 of the License, or (at your
14 dnl option
) any later version.
18 dnl
* the GNU General
Public License as published by the Free Software
19 dnl Foundation
; either version 2 of the License, or (at your option) any
22 dnl
or both
in parallel
, as here.
24 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
25 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
26 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
29 dnl You should have received copies of the GNU General
Public License
and the
30 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
31 dnl see
https://www.gnu.
org/licenses
/.
33 include(`..
/config.m4
')
44 C Some useful aliases for registers we use
45 define(`u0',`r14
') define(`u1',`r15
') define(`u2',`r16
')
46 define(`a0',`r17
') define(`a1',`r18
') define(`a2',`r19
')
47 define(`c0',`r20
') define(`c1',`r21
') define(`c2',`r22
')
49 C This is a fairly simple-minded implementation. One could approach 0.67 c/l
50 C with a more sophisticated implementation. If we're really crazy
, we could
51 C super
-unroll
, storing carries just
in predicate registers
, then copy them to
52 C a general register
, and population count them from there. That
'd bring us
53 C close to 3 insn/limb, for nearly 0.5 c/l.
55 C Computing n/3 needs 16 cycles, which is a lot of startup overhead.
56 C We therefore use a plain while-style loop:
58 C cmp.le p9, p0 = 3, n
60 C Alternatively, we could table n/3 for, say, n < 256, and predicate the
63 C The summing-up code at the end was written quickly, and could surely be
67 PROLOGUE(mpn_mod_34lsub1)
72 addp4 up
= 0, up C M I
79 movl r14 = 0xAAAAAAAAAAAAAAAB
88 shr.u r8 = r8, 1 C Loop count
112 }{.mmi; ld8 u1 = [up], 8
114 cmp.ltu p6, p0 = r0, r0 C clear p6
115 }{.mmb; cmp.gt p9, p0 = 3, n
117 (p9) br.cond.dptk L(end)
122 {.mmi; ld8 u2 = [up], 8
124 cmp.ltu p7, p0 = a0, u0
125 }{.mmb; sub a0 = a0, u0
129 }{.mmi; ld8 u0 = [up], 8
131 cmp.ltu p8, p0 = a1, u1
132 }{.mmb; sub a1 = a1, u1
136 }{.mmi; ld8 u1 = [up], 8
138 cmp.ltu p6, p0 = a2, u2
139 }{.mmb; sub a2 = a2, u2
141 dnl br.cloop.dptk L(top)
142 (p9) br.cond.dptk L(top)
146 cmp.
eq p10
, p0
= 0, n
147 cmp.
eq p11
, p0
= 1, n
151 {.mmi; ld8 u2 = [up], 8
153 cmp.ltu p7, p0 = a0, u0
154 }{.mmb; sub a0 = a0, u0
160 cmp.ltu p8
, p0
= a1
, u1
164 cmp.ltu p6
, p0
= a2
, u2
168 cmp.ltu p7
, p0
= a0
, u0
177 cmp.ltu p8
, p0
= a1
, u1
181 cmp.ltu p6
, p0
= a2
, u2
190 cmp.ltu p7
, p0
= a0
, u0
194 cmp.ltu p8
, p0
= a1
, u1
202 shr.u r24
= a0
, 48 C
16 bits
203 shr.u r25
= a1
, 32 C
32 bits
204 shr.u r26
= a2
, 16 C
48 bits
206 shr.u r10
= c0
, 48 C
16 bits
, always zero
207 shr.u r11
= c1
, 32 C
32 bits
208 shr.u r30
= c2
, 16 C
48 bits
210 dep.z r27
= a0
, 0, 48 C
48 bits
211 dep.z r28
= a1
, 16, 32 C
48 bits
212 dep.z r29
= a2
, 32, 16 C
48 bits
213 dep.z r31
= c0
, 0, 48 C
48 bits
214 dep.z r14
= c1
, 16, 32 C
48 bits
215 dep.z r15
= c2
, 32, 16 C
48 bits
217 {.mmi; add r24 = r24, r25
220 }{.mmi; add r10 = r10, r11
225 movl r8
= 0xffffffffffff0