| 1 |
dnl AMD64 mpn_addaddmul_1msb0, R = Au + Bv, u,v < 2^63. |
| 2 |
|
| 3 |
dnl Copyright 2008, 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 AMD K8,K9 2.167 |
| 35 |
C AMD K10 2.167 |
| 36 |
C Intel P4 12.0 |
| 37 |
C Intel core2 4.0 |
| 38 |
C Intel corei ? |
| 39 |
C Intel atom ? |
| 40 |
C VIA nano ? |
| 41 |
|
| 42 |
C TODO |
| 43 |
C * Perhaps handle various n mod 3 sizes better. The code now is too large. |
| 44 |
|
| 45 |
C INPUT PARAMETERS |
| 46 |
define(`rp', `%rdi') |
| 47 |
define(`ap', `%rsi') |
| 48 |
define(`bp_param', `%rdx') |
| 49 |
define(`n', `%rcx') |
| 50 |
define(`u0', `%r8') |
| 51 |
define(`v0', `%r9') |
| 52 |
|
| 53 |
|
| 54 |
define(`bp', `%rbp') |
| 55 |
|
| 56 |
ABI_SUPPORT(DOS64) |
| 57 |
ABI_SUPPORT(STD64) |
| 58 |
|
| 59 |
ASM_START() |
| 60 |
TEXT |
| 61 |
ALIGN(16) |
| 62 |
PROLOGUE(mpn_addaddmul_1msb0) |
| 63 |
FUNC_ENTRY(4) |
| 64 |
IFDOS(` mov 56(%rsp), %r8 ') |
| 65 |
IFDOS(` mov 64(%rsp), %r9 ') |
| 66 |
push %rbp |
| 67 |
|
| 68 |
lea (ap,n,8), ap |
| 69 |
lea (bp_param,n,8), bp |
| 70 |
lea (rp,n,8), rp |
| 71 |
neg n |
| 72 |
|
| 73 |
mov (ap,n,8), %rax |
| 74 |
mul %r8 |
| 75 |
mov %rax, %r11 |
| 76 |
mov (bp,n,8), %rax |
| 77 |
mov %rdx, %r10 |
| 78 |
add $3, n |
| 79 |
jns L(end) |
| 80 |
|
| 81 |
push %r13 |
| 82 |
|
| 83 |
ALIGN(16) |
| 84 |
L(top): mul %r9 |
| 85 |
add %rax, %r11 |
| 86 |
mov -16(ap,n,8), %rax |
| 87 |
adc %rdx, %r10 |
| 88 |
mov %r11, -24(rp,n,8) |
| 89 |
mul %r8 |
| 90 |
add %rax, %r10 |
| 91 |
mov -16(bp,n,8), %rax |
| 92 |
mov $0, R32(%r13) |
| 93 |
adc %rdx, %r13 |
| 94 |
mul %r9 |
| 95 |
add %rax, %r10 |
| 96 |
mov -8(ap,n,8), %rax |
| 97 |
adc %rdx, %r13 |
| 98 |
mov %r10, -16(rp,n,8) |
| 99 |
mul %r8 |
| 100 |
add %rax, %r13 |
| 101 |
mov -8(bp,n,8), %rax |
| 102 |
mov $0, R32(%r11) |
| 103 |
adc %rdx, %r11 |
| 104 |
mul %r9 |
| 105 |
add %rax, %r13 |
| 106 |
adc %rdx, %r11 |
| 107 |
mov (ap,n,8), %rax |
| 108 |
mul %r8 |
| 109 |
add %rax, %r11 |
| 110 |
mov %r13, -8(rp,n,8) |
| 111 |
mov (bp,n,8), %rax |
| 112 |
mov $0, R32(%r10) |
| 113 |
adc %rdx, %r10 |
| 114 |
add $3, n |
| 115 |
js L(top) |
| 116 |
|
| 117 |
pop %r13 |
| 118 |
|
| 119 |
L(end): mul %r9 |
| 120 |
add %rax, %r11 |
| 121 |
adc %rdx, %r10 |
| 122 |
cmp $1, R32(n) |
| 123 |
ja L(two) |
| 124 |
mov -16(ap,n,8), %rax |
| 125 |
mov %r11, -24(rp,n,8) |
| 126 |
mov %r10, %r11 |
| 127 |
jz L(one) |
| 128 |
|
| 129 |
L(nul): mul %r8 |
| 130 |
add %rax, %r10 |
| 131 |
mov -16(bp), %rax |
| 132 |
mov $0, R32(%r11) |
| 133 |
adc %rdx, %r11 |
| 134 |
mul %r9 |
| 135 |
add %rax, %r10 |
| 136 |
mov -8(ap), %rax |
| 137 |
adc %rdx, %r11 |
| 138 |
mov %r10, -16(rp) |
| 139 |
L(one): mul %r8 |
| 140 |
add %rax, %r11 |
| 141 |
mov -8(bp), %rax |
| 142 |
mov $0, R32(%r10) |
| 143 |
adc %rdx, %r10 |
| 144 |
mul %r9 |
| 145 |
add %rax, %r11 |
| 146 |
adc %rdx, %r10 |
| 147 |
|
| 148 |
L(two): mov %r11, -8(rp) |
| 149 |
mov %r10, %rax |
| 150 |
L(ret): pop %rbp |
| 151 |
FUNC_EXIT() |
| 152 |
ret |
| 153 |
EPILOGUE() |