| 1 |
dnl PowerPC-64 mpn_modexact_1_odd -- mpn by limb exact remainder. |
| 2 |
|
| 3 |
dnl Copyright 2006 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
dnl This file is part of the GNU MP Library. |
| 6 |
dnl |
| 7 |
dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 8 |
dnl it under the terms of either: |
| 9 |
dnl |
| 10 |
dnl * the GNU Lesser General Public License as published by the Free |
| 11 |
dnl Software Foundation; either version 3 of the License, or (at your |
| 12 |
dnl option) any later version. |
| 13 |
dnl |
| 14 |
dnl or |
| 15 |
dnl |
| 16 |
dnl * the GNU General Public License as published by the Free Software |
| 17 |
dnl Foundation; either version 2 of the License, or (at your option) any |
| 18 |
dnl later version. |
| 19 |
dnl |
| 20 |
dnl or both in parallel, as here. |
| 21 |
dnl |
| 22 |
dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 23 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 24 |
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 25 |
dnl for more details. |
| 26 |
dnl |
| 27 |
dnl You should have received copies of the GNU General Public License and the |
| 28 |
dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 29 |
dnl see https://www.gnu.org/licenses/. |
| 30 |
|
| 31 |
include(`../config.m4') |
| 32 |
|
| 33 |
C cycles/limb |
| 34 |
C POWER3/PPC630 13-19 |
| 35 |
C POWER4/PPC970 16 |
| 36 |
C POWER5 16 |
| 37 |
C POWER6 ? |
| 38 |
C POWER7 12 |
| 39 |
|
| 40 |
C TODO |
| 41 |
C * Check if n=1 code is really an improvement. It probably isn't. |
| 42 |
C * Make more similar to dive_1.asm. |
| 43 |
|
| 44 |
C INPUT PARAMETERS |
| 45 |
define(`up', `r3') |
| 46 |
define(`n', `r4') |
| 47 |
define(`d', `r5') |
| 48 |
define(`cy', `r6') |
| 49 |
|
| 50 |
|
| 51 |
ASM_START() |
| 52 |
|
| 53 |
EXTERN(binvert_limb_table) |
| 54 |
|
| 55 |
PROLOGUE(mpn_modexact_1c_odd,toc) |
| 56 |
addic. n, n, -1 C set carry as side effect |
| 57 |
ld r8, 0(up) |
| 58 |
bne cr0, L(2) |
| 59 |
cmpld cr7, r6, r8 |
| 60 |
bge cr7, L(4) |
| 61 |
subf r8, r6, r8 |
| 62 |
divdu r3, r8, d |
| 63 |
mulld r3, r3, d |
| 64 |
subf. r3, r3, r8 |
| 65 |
beqlr cr0 |
| 66 |
subf r3, r3, d |
| 67 |
blr |
| 68 |
|
| 69 |
L(4): subf r3, r8, r6 |
| 70 |
divdu r8, r3, d |
| 71 |
mulld r8, r8, d |
| 72 |
subf r3, r8, r3 |
| 73 |
blr |
| 74 |
|
| 75 |
L(2): LEA( r7, binvert_limb_table) |
| 76 |
rldicl r9, d, 63, 57 |
| 77 |
mtctr n |
| 78 |
lbzx r0, r7, r9 |
| 79 |
mulld r7, r0, r0 |
| 80 |
sldi r0, r0, 1 |
| 81 |
mulld r7, d, r7 |
| 82 |
subf r0, r7, r0 |
| 83 |
mulld r9, r0, r0 |
| 84 |
sldi r0, r0, 1 |
| 85 |
mulld r9, d, r9 |
| 86 |
subf r0, r9, r0 |
| 87 |
mulld r7, r0, r0 |
| 88 |
sldi r0, r0, 1 |
| 89 |
mulld r7, d, r7 |
| 90 |
subf r9, r7, r0 |
| 91 |
|
| 92 |
ALIGN(16) |
| 93 |
L(loop): |
| 94 |
subfe r0, r6, r8 |
| 95 |
ld r8, 8(up) |
| 96 |
addi up, up, 8 |
| 97 |
mulld r0, r9, r0 |
| 98 |
mulhdu r6, r0, d |
| 99 |
bdnz L(loop) |
| 100 |
|
| 101 |
cmpld cr7, d, r8 |
| 102 |
blt cr7, L(10) |
| 103 |
|
| 104 |
subfe r0, r0, r0 |
| 105 |
subf r6, r0, r6 |
| 106 |
cmpld cr7, r6, r8 |
| 107 |
subf r3, r8, r6 |
| 108 |
bgelr cr7 |
| 109 |
add r3, d, r3 |
| 110 |
blr |
| 111 |
|
| 112 |
L(10): subfe r0, r6, r8 |
| 113 |
mulld r0, r9, r0 |
| 114 |
mulhdu r3, r0, d |
| 115 |
blr |
| 116 |
EPILOGUE() |
| 117 |
ASM_END() |