| 1 |
dnl Power9 mpn_addaddmul_1msb0 |
| 2 |
|
| 3 |
dnl Copyright 2021 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 1-way 2-way 4-way 8-way 16-way mul_1+addmul_1 |
| 35 |
C power9: 4.55 3.87 3.55 3.35 3.25 5.16 |
| 36 |
|
| 37 |
C TODO |
| 38 |
C * Only WAYS = 4 currently has proper feed-in code. |
| 39 |
C * Try ldu/stdu to save the explicit updates. |
| 40 |
C * Try using madd in a long dependent chain, only breaking the recurrency |
| 41 |
C once per iteration. |
| 42 |
C * Some cycles could perhaps be saved by scheduling the crX-setting insns. |
| 43 |
|
| 44 |
define(`rp', r3) |
| 45 |
define(`ap', r4) |
| 46 |
define(`bp', r5) |
| 47 |
define(`n', r6) |
| 48 |
define(`u0', r7) |
| 49 |
define(`v0', r8) |
| 50 |
|
| 51 |
define(`BLOCK',` |
| 52 |
L(lo`'eval((WAYS-$1)%4)): |
| 53 |
ld r10, eval(8*$1)(ap) |
| 54 |
ld r11, eval(8*$1)(bp) |
| 55 |
mulld r12, r10, u0 |
| 56 |
mulhdu r10, r10, u0 |
| 57 |
maddld( r6, r11, v0, r12) |
| 58 |
maddhdu(r11, r11, v0, r12) |
| 59 |
adde r12, r6, r0 |
| 60 |
std r12, eval(8*$1)(rp) |
| 61 |
add r0, r10, r11') |
| 62 |
|
| 63 |
ifdef(`WAYS',,`define(`WAYS',4)') |
| 64 |
|
| 65 |
PROLOGUE(mpn_addaddmul_1msb0) |
| 66 |
addi r10, n, WAYS-1 |
| 67 |
srdi r10, r10, m4_log2(WAYS) |
| 68 |
mtctr r10 |
| 69 |
addic r0, r3, 0 |
| 70 |
li r0, 0 |
| 71 |
ifelse(WAYS,4,` |
| 72 |
rldicl. r9, n, 0, 63 |
| 73 |
rldicl r10, n, 63, 63 |
| 74 |
cmpdi cr7, r10, 0 |
| 75 |
bne cr0, L(bx1) |
| 76 |
|
| 77 |
L(bx0): beq cr7, L(lo0) |
| 78 |
|
| 79 |
L(b10): addi ap, ap, -16 |
| 80 |
addi bp, bp, -16 |
| 81 |
addi rp, rp, -16 |
| 82 |
b L(lo2) |
| 83 |
|
| 84 |
L(bx1): bne cr7, L(b11) |
| 85 |
|
| 86 |
L(b01): addi ap, ap, -24 |
| 87 |
addi bp, bp, -24 |
| 88 |
addi rp, rp, -24 |
| 89 |
b L(lo1) |
| 90 |
|
| 91 |
L(b11): addi ap, ap, -8 |
| 92 |
addi bp, bp, -8 |
| 93 |
addi rp, rp, -8 |
| 94 |
b L(lo3) |
| 95 |
') |
| 96 |
|
| 97 |
L(top): forloop(i,0,eval(WAYS-1),`BLOCK(i)') |
| 98 |
|
| 99 |
addi ap, ap, eval(8*WAYS) |
| 100 |
addi bp, bp, eval(8*WAYS) |
| 101 |
addi rp, rp, eval(8*WAYS) |
| 102 |
bdnz L(top) |
| 103 |
|
| 104 |
addze r3, r0 |
| 105 |
blr |
| 106 |
EPILOGUE() |