1 dnl IA
-64 mpn_popcount
-- mpn population count.
3 dnl Contributed to the GNU project by Torbjorn Granlund.
5 dnl Copyright
2000-2005 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
')
43 define(`u0',`r16
') define(`u1',`r17
') define(`u2',`r18
') define(`u3',`r19
')
44 define(`c0',`r28
') define(`c1',`r29
') define(`c2',`r30
') define(`c3',`r31
')
49 PROLOGUE(mpn_popcount)
52 ` addp4 up
= 0, up C M I
58 {.mmi; add r9 = 512, up C prefetch pointer M I
59 ld8 r10 = [up], 8 C load first limb M01
60 mov.i r2 = ar.lc C save ar.lc I0
61 }{.mmi; and r14 = 3, n C M I
62 cmp.lt p15, p14 = 4, n C small count? M I
65 }{.mmi; cmp.eq p6, p0 = 1, r14 C M I
66 cmp.eq p7, p0 = 2, r14 C M I
67 cmp.eq p8, p0 = 3, r14 C M I
69 (p6) br.dptk .Lb01 C B
70 (p7) br.dptk .Lb10 C B
71 (p8) br.dptk .Lb11 C B
75 .Lb00: ld8 u1 = [up], 8 C M01
79 ld8 u2 = [up], 8 C M01
83 ld8 u3 = [up], 8 C M01
85 (p15) br.cond.dptk .grt4 C B
95 .grt4: ld8 u0 = [up], 8 C M01
102 (p14) br.ret.sptk.many b0 C B
104 .grt1: ld8 u0 = [up], 8 C M01
107 ld8 u1 = [up], 8 C M01
110 ld8 u2 = [up], 8 C M01
115 ld8 u3 = [up], 8 C M01
117 br.cloop.dptk .Loop C B
121 .Lb10: ld8 u3 = [up], 8 C M01
123 (p15) br.cond.dptk .grt2 C B
130 .grt2: ld8 u0 = [up], 8 C M01
134 ld8 u1 = [up], 8 C M01
138 ld8 u2 = [up], 8 C M01
143 .Lb11: ld8 u2 = [up], 8 C M01
147 ld8 u3 = [up], 8 C M01
149 (p15) br.cond.dptk .grt3 C B
156 .grt3: ld8 u0 = [up], 8 C M01
161 ld8 u1 = [up], 8 C M01
166 .Loop: ld8 u0 = [up], 8 C M01
170 .LL00: ld8 u1 = [up], 8 C M01
174 .LL11: ld8 u2 = [up], 8 C M01
178 .LL10: ld8 u3 = [up], 8 C M01
181 lfetch [r9], 32 C M01
183 br.cloop.dptk .Loop C B
186 .Lend: popcnt c2 = u2 C I0
192 .Lcj4: add s = s, c1 C M I
194 .Lcj3: add s = s, c2 C M I
196 .Lcj2: add s = s, c3 C M I
197 mov.i ar.lc = r2 C I0
198 br.ret.sptk.many b0 C B