dnl AMD64 mpn_mul_basecase optimised for Intel Sandy bridge and Ivy bridge.
dnl Contributed to the GNU project by Torbjörn Granlund.
dnl Copyright 2003-2005, 2007, 2008, 2011-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 mul_1 mul_2 mul_3 addmul_2
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 2.5 2.5 - 2.95
C Intel IBR 2.4 2.3 - 2.68
C Intel HWL 2.35 2.0 - 2.5
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 Torbjorn Granlund.
C TODO
C * Fix the addmul_2 fluctuation affecting SBR.
C * Improve feed-in code, avoiding zeroing of many registers and dummy adds in
C the loops at the expense of code size.
C * Adjoin a mul_3, avoiding slow mul_1 for odd vn.
C * Consider replacing the 2-way mul_2 code with 4-way code, for a very slight
C speedup.
C * Further micro-optimise.
C When playing with pointers, set this to $2 to fall back to conservative
C indexing in wind-down code.
define(`I',`$1')
ASM_START()
TEXT ALIGN(16)
PROLOGUE(mpn_mul_basecase)
FUNC_ENTRY(4)
IFDOS(` mov 56(%rsp), %r8d ') push %rbx push %rbp mov un_param, un C free up rdx neg un
mov (up), %rax C shared for mul_1 and mul_2 lea (up,un_param,8), up C point at operand end lea (rp,un_param,8), rp C point at rp[un-1]
mov (vp), v0 C shared for mul_1 and mul_2 mul v0 C shared for mul_1 and mul_2
test $1, R8(vn) jz L(do_mul_2)
L(do_mul_1):
test $1, R8(un) jnz L(m1x1)
L(m1x0):mov %rax, w0 C un = 2, 4, 6, 8, ... mov %rdx, w1 mov 8(up,un,8), %rax
test $2, R8(un) jnz L(m110)
L(m100):lea 2(un), n C un = 4, 8, 12, ... jmp L(m1l0)
L(m110):lea (un), n C un = 2, 6, 10, ... jmp L(m1l2)
L(m1x1):mov %rax, w1 C un = 1, 3, 5, 7, ... mov %rdx, w0
test $2, R8(un) jz L(m111)
L(m101):lea 3(un), n C un = 1, 5, 9, ...
test n, n
js L(m1l1) mov %rax, -8(rp) mov %rdx, (rp) pop %rbp pop %rbx
FUNC_EXIT() ret
L(m111):lea 1(un), n C un = 3, 7, 11, ... mov 8(up,un,8), %rax jmp L(m1l3)
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.