| 1 |
dnl PowerPC-64 mpn_mod_34lsub1 -- modulo 2^48-1. |
| 2 |
|
| 3 |
dnl Copyright 2005 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 1.33 |
| 35 |
C POWER4/PPC970 1.5 |
| 36 |
C POWER5 1.32 |
| 37 |
C POWER6 2.35 |
| 38 |
C POWER7 1 |
| 39 |
|
| 40 |
C INPUT PARAMETERS |
| 41 |
define(`up',`r3') |
| 42 |
define(`n',`r4') |
| 43 |
|
| 44 |
ASM_START() |
| 45 |
PROLOGUE(mpn_mod_34lsub1) |
| 46 |
li r8, 0 |
| 47 |
li r9, 0 |
| 48 |
li r10, 0 |
| 49 |
li r11, 0 |
| 50 |
|
| 51 |
cmpdi cr6, n, 3 |
| 52 |
blt cr6, L(lt3) |
| 53 |
|
| 54 |
li r0, -0x5556 C 0xFFFFFFFFFFFFAAAA |
| 55 |
rldimi r0, r0, 16, 32 C 0xFFFFFFFFAAAAAAAA |
| 56 |
rldimi r0, r0, 32, 63 C 0xAAAAAAAAAAAAAAAB |
| 57 |
mulhdu r0, r0, n |
| 58 |
srdi r0, r0, 1 C r0 = [n / 3] |
| 59 |
mtctr r0 |
| 60 |
|
| 61 |
ld r5, 0(up) |
| 62 |
ld r6, 8(up) |
| 63 |
ld r7, 16(up) |
| 64 |
addi up, up, 24 |
| 65 |
bdz L(end) |
| 66 |
|
| 67 |
ALIGN(16) |
| 68 |
L(top): addc r8, r8, r5 |
| 69 |
nop |
| 70 |
ld r5, 0(up) |
| 71 |
adde r9, r9, r6 |
| 72 |
ld r6, 8(up) |
| 73 |
adde r10, r10, r7 |
| 74 |
ld r7, 16(up) |
| 75 |
addi up, up, 48 |
| 76 |
addze r11, r11 |
| 77 |
bdz L(endx) |
| 78 |
addc r8, r8, r5 |
| 79 |
nop |
| 80 |
ld r5, -24(up) |
| 81 |
adde r9, r9, r6 |
| 82 |
ld r6, -16(up) |
| 83 |
adde r10, r10, r7 |
| 84 |
ld r7, -8(up) |
| 85 |
addze r11, r11 |
| 86 |
bdnz L(top) |
| 87 |
|
| 88 |
addi up, up, 24 |
| 89 |
L(endx): |
| 90 |
addi up, up, -24 |
| 91 |
|
| 92 |
L(end): addc r8, r8, r5 |
| 93 |
adde r9, r9, r6 |
| 94 |
adde r10, r10, r7 |
| 95 |
addze r11, r11 |
| 96 |
|
| 97 |
sldi r5, r0, 1 |
| 98 |
add r5, r5, r0 C r11 = n / 3 * 3 |
| 99 |
sub n, n, r5 C n = n mod 3 |
| 100 |
L(lt3): cmpdi cr6, n, 1 |
| 101 |
blt cr6, L(2) |
| 102 |
|
| 103 |
ld r5, 0(up) |
| 104 |
addc r8, r8, r5 |
| 105 |
li r6, 0 |
| 106 |
beq cr6, L(1) |
| 107 |
|
| 108 |
ld r6, 8(up) |
| 109 |
L(1): adde r9, r9, r6 |
| 110 |
addze r10, r10 |
| 111 |
addze r11, r11 |
| 112 |
|
| 113 |
L(2): rldicl r0, r8, 0, 16 C r0 = r8 mod 2^48 |
| 114 |
srdi r3, r8, 48 C r3 = r8 div 2^48 |
| 115 |
rldic r4, r9, 16, 16 C r4 = (r9 mod 2^32) << 16 |
| 116 |
srdi r5, r9, 32 C r5 = r9 div 2^32 |
| 117 |
rldic r6, r10, 32, 16 C r6 = (r10 mod 2^16) << 32 |
| 118 |
srdi r7, r10, 16 C r7 = r10 div 2^16 |
| 119 |
|
| 120 |
add r0, r0, r3 |
| 121 |
add r4, r4, r5 |
| 122 |
add r6, r6, r7 |
| 123 |
|
| 124 |
add r0, r0, r4 |
| 125 |
add r6, r6, r11 |
| 126 |
|
| 127 |
add r3, r0, r6 |
| 128 |
blr |
| 129 |
EPILOGUE() |
| 130 |
|
| 131 |
C |__r10__|__r9___|__r8___| |
| 132 |
C |-----|-----|-----|-----| |