dnl Contributed to the GNU project by Torbjörn Granlund.
dnl Copyright 2004, 2008, 2013 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C AMD K8,K9 ?
C AMD K10 ?
C AMD bull ?
C AMD pile ?
C AMD steam ?
C AMD bobcat ?
C AMD jaguar ?
C Intel P4 ?
C Intel core ?
C Intel NHM ?
C Intel SBR ?
C Intel IBR ?
C Intel HWL ?
C Intel BWL ?
C Intel atom ?
C VIA nano ?
C The inner loops of thiscode are the result of running a code generation and
C optimisation tool suite written by David Harvey and Torbjörn Granlund.
C TODO
C * Micro-optimise, none performed thus far.
C * This looks different from other current redc_1.asm variants. Consider
C adapting this to the mainstream style.
C * Is thiscode really faster than more approaches which compute q0 later?
C Is the use of a jump jump table faster? Or is the edge of this due to the
C inlined add_n code?
C * Put initial m[0] x q0 computation in header.
C * Put basecases at the file's end, single them out before the pushes.
define(`rp', `%rdi') C rcx
define(`up', `%rsi') C rdx
define(`mp_param', `%rdx') C r8
define(`n', `%rcx') C r9
define(`u0inv', `%r8') C stack
ALIGN(16)
L(li0): add %r10, (up,i,8) adc %rax, %r9
mov (mp,i,8), %rax adc %rdx, %r14 xor R32(%r10), R32(%r10) mul q0
add %r9, 8(up,i,8) adc %rax, %r14 adc %rdx, %rbx
mov 8(mp,i,8), %rax mul q0
add %r14, 16(up,i,8) adc %rax, %rbx adc %rdx, %r10
L(e0): mov 16(mp,i,8), %rax mul q0
add %rbx, 24(up,i,8)
mov $0, R32(%r14) C zero
mov %r14, %rbx C zero adc %rax, %r10
mov 24(mp,i,8), %rax
mov %r14, %r9 C zero adc %rdx, %r9 mul q0
add $4, i
js L(li0)
L(le0): add %r10, (up) adc %rax, %r9 adc %r14, %rdx
add %r9, 8(up) adc $0, %rdx
mov %rdx, 16(up,nneg,8) C up[0]
add $8, up
mov %r15, q0
dec n jnz L(lo0)
mov nneg, n
sar $2, n
clc
lea 16(up,nneg,8), up
lea (up,nneg,8), vp
jmp L(addy)
ALIGN(16)
L(3m4):
L(lo3): mov (mp,nneg,8), %rax mul q0
mov %rax, %rbx
mov %rdx, %r10
mov 8(mp,nneg,8), %rax
mov 24(up,nneg,8), %r15 mul q0
add 16(up,nneg,8), %rbx C result is zero, might carry
mov $0, R32(%rbx) C zero
mov %rbx, %r14 C zero adc %rax, %r10
mov 16(mp,nneg,8), %rax
mov %r14, %r9 C zero adc %rdx, %r9
add %r10, %r15 mul q0
lea 3(nneg), i
imul u0inv, %r15
C jmp L(li3)
ALIGN(16)
L(li3): add %r10, (up,i,8) adc %rax, %r9
mov (mp,i,8), %rax adc %rdx, %r14 xor R32(%r10), R32(%r10) mul q0
add %r9, 8(up,i,8) adc %rax, %r14 adc %rdx, %rbx
mov 8(mp,i,8), %rax mul q0
add %r14, 16(up,i,8) adc %rax, %rbx adc %rdx, %r10
mov 16(mp,i,8), %rax mul q0
add %rbx, 24(up,i,8)
mov $0, R32(%r14) C zero
mov %r14, %rbx C zero adc %rax, %r10
mov 24(mp,i,8), %rax
mov %r14, %r9 C zero adc %rdx, %r9 mul q0
add $4, i
js L(li3)
L(le3): add %r10, (up) adc %rax, %r9 adc %r14, %rdx
add %r9, 8(up) adc $0, %rdx
mov %rdx, 16(up,nneg,8) C up[0]
mov %r15, q0
lea 8(up), up
dec n jnz L(lo3)
C ==== Addition code ====
mov nneg, n
sar $2, n
lea 40(up,nneg,8), up
lea (up,nneg,8), vp
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.