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 4.5
C AMD K10 4.5
C AMD bd1 4.75
C AMD bobcat 5
C Intel P4 17.7
C Intel core2 5.5
C Intel NHM 5.43
C Intel SBR 3.92
C Intel atom 23
C VIA nano 5.63
C This sqr_basecase is based on mul_1 and addmul_1, since these both run at the
C multiply insn bandwidth, without any apparent loop branch exit pipeline
C replays experienced on K8. The structure is unusual: it falls into mul_1 in
C the same way for all n, then it splits into 4 different wind-down blocks and
C 4 separate addmul_1 loops.
C
C We have not tried using the same addmul_1 loops with a switch into feed-in
C code, as we do in other basecase implementations. Doing that could save
C substantial code volume, but would also probably add some overhead.
C TODO
C * Tune un < 4 code.
C * Perhaps implement a larger final corner (it is now 2 x 1).
C * Lots of space could be saved by replacing the "switch"code by gradual
C jumps out from mul_1 winddown code, perhaps with no added overhead.
C * Are the ALIGN(16) really necessary? They add about 25 bytes of padding.
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
C Standard parameters
define(`rp', `%rdi')
define(`up', `%rsi')
define(`un_param', `%rdx')
C Standard allocations
define(`un', `%rbx')
define(`w0', `%r8')
define(`w1', `%r9')
define(`w2', `%r10')
define(`w3', `%r11')
define(`n', `%rbp')
define(`v0', `%rcx')
C Temp macrofor allowing control over indexing.
C Define to return $1 for more conservative ptr handling.
define(`X',`$2')
dnl define(`X',`$1')
ASM_START()
TEXT ALIGN(64)
PROLOGUE(mpn_sqr_basecase)
FUNC_ENTRY(3)
mov (up), %rax
cmp $2, R32(un_param)
jae L(ge2)
mul %rax mov %rax, (rp) mov %rdx, 8(rp)
FUNC_EXIT() ret
mov 8(up), %rax lea -24(rp,un_param,8), rp lea -24(up,un_param,8), up neg un_param push un_param C for sqr_diag_addlsh1 lea (un_param), un lea 3(un_param), n
L(r0): mov X((up,n,8),16(up)), %rax mul v0 mov %rax, w0 mov %rdx, w1 mov w2, X(-8(rp,n,8),8(rp)) add w3, w0 adc $0, w1 mov w0, X((rp,n,8),16(rp)) mov w1, X(8(rp,n,8),24(rp)) add $4, un
C jmp L(to3)
C fall through into main loop
L(outer): mov un, n mov (up,un,8), v0 mov 8(up,un,8), %rax lea 8(rp), rp mul v0 mov %rax, w2 mov %rdx, w3 jmp L(al3)
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.