popcount.asm revision 1.1.1.1
1dnl PowerPC-64 mpn_popcount. 2 3dnl Copyright 2012 Free Software Foundation, Inc. 4 5dnl This file is part of the GNU MP Library. 6 7dnl The GNU MP Library is free software; you can redistribute it and/or modify 8dnl it under the terms of the GNU Lesser General Public License as published 9dnl by the Free Software Foundation; either version 3 of the License, or (at 10dnl your option) any later version. 11 12dnl The GNU MP Library is distributed in the hope that it will be useful, but 13dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15dnl License for more details. 16 17dnl You should have received a copy of the GNU Lesser General Public License 18dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 20include(`../config.m4') 21 22C cycles/limb 23C POWER3/PPC630 - 24C POWER4/PPC970 - 25C POWER5 - 26C POWER6 - 27C POWER7 2 28 29define(`up', r3) 30define(`n', r4) 31 32ASM_START() 33PROLOGUE(mpn_popcount) 34 addi r0, n, 1 35ifdef(`HAVE_ABI_mode32', 36` rldicl r0, r0, 63,33', C ...branch count 37` srdi r0, r0, 1') C ...for ctr 38 mtctr r0 39 40 andi. r0, n, 1 41 42 li r0, 0 43 li r12, 0 44 beq L(evn) 45 46L(odd): ld r4, 0(up) 47 addi up, up, 8 48 popcntd r0, r4 49 bdz L(e1) 50 51L(evn): ld r4, 0(up) 52 ld r5, 8(up) 53 popcntd r8, r4 54 popcntd r9, r5 55 bdz L(e2) 56 57 ld r4, 16(up) 58 ld r5, 24(up) 59 bdz L(e4) 60 addi up, up, 32 61 62L(top): add r0, r0, r8 63 popcntd r8, r4 64 ld r4, 0(up) 65 add r12, r12, r9 66 popcntd r9, r5 67 ld r5, 8(up) 68 addi up, up, 16 69 bdnz L(top) 70 71L(e4): add r0, r0, r8 72 popcntd r8, r4 73 add r12, r12, r9 74 popcntd r9, r5 75L(e2): add r0, r0, r8 76 add r12, r12, r9 77L(e1): add r3, r0, r12 78 blr 79EPILOGUE() 80