| 1 |
dnl AMD64 mpn_gcd_11 optimised for AMD BD2, BD3, BT2. |
| 2 |
|
| 3 |
dnl Based on the K7 gcd_1.asm, by Kevin Ryde. Rehacked for AMD64 by Torbjorn |
| 4 |
dnl Granlund. |
| 5 |
|
| 6 |
dnl Copyright 2000-2002, 2005, 2009, 2011, 2012, 2017, 2019 Free Software |
| 7 |
dnl Foundation, Inc. |
| 8 |
|
| 9 |
dnl This file is part of the GNU MP Library. |
| 10 |
dnl |
| 11 |
dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 12 |
dnl it under the terms of either: |
| 13 |
dnl |
| 14 |
dnl * the GNU Lesser General Public License as published by the Free |
| 15 |
dnl Software Foundation; either version 3 of the License, or (at your |
| 16 |
dnl option) any later version. |
| 17 |
dnl |
| 18 |
dnl or |
| 19 |
dnl |
| 20 |
dnl * the GNU General Public License as published by the Free Software |
| 21 |
dnl Foundation; either version 2 of the License, or (at your option) any |
| 22 |
dnl later version. |
| 23 |
dnl |
| 24 |
dnl or both in parallel, as here. |
| 25 |
dnl |
| 26 |
dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 27 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 28 |
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 29 |
dnl for more details. |
| 30 |
dnl |
| 31 |
dnl You should have received copies of the GNU General Public License and the |
| 32 |
dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 33 |
dnl see https://www.gnu.org/licenses/. |
| 34 |
|
| 35 |
include(`../config.m4') |
| 36 |
|
| 37 |
|
| 38 |
C cycles/bit (approx) |
| 39 |
C AMD K8,K9 ? |
| 40 |
C AMD K10 ? |
| 41 |
C AMD bd1 5.4 |
| 42 |
C AMD bd2 3.72 |
| 43 |
C AMD bd3 ? |
| 44 |
C AMD bd4 4.12 |
| 45 |
C AMD bt1 9.0 |
| 46 |
C AMD bt2 3.97 |
| 47 |
C AMD zn1 3.36 |
| 48 |
C AMD zn2 3.33 |
| 49 |
C Intel P4 ? |
| 50 |
C Intel CNR ? |
| 51 |
C Intel PNR ? |
| 52 |
C Intel NHM ? |
| 53 |
C Intel WSM ? |
| 54 |
C Intel SBR ? |
| 55 |
C Intel IBR ? |
| 56 |
C Intel HWL ? |
| 57 |
C Intel BWL ? |
| 58 |
C Intel SKL ? |
| 59 |
C Intel atom ? |
| 60 |
C Intel SLM ? |
| 61 |
C Intel GLM ? |
| 62 |
C Intel GLM+ ? |
| 63 |
C VIA nano ? |
| 64 |
|
| 65 |
define(`u0', `%rdi') |
| 66 |
define(`v0', `%rsi') |
| 67 |
|
| 68 |
ABI_SUPPORT(DOS64) |
| 69 |
ABI_SUPPORT(STD64) |
| 70 |
|
| 71 |
ASM_START() |
| 72 |
TEXT |
| 73 |
ALIGN(64) |
| 74 |
PROLOGUE(mpn_gcd_11) |
| 75 |
FUNC_ENTRY(2) |
| 76 |
mov v0, %rdx |
| 77 |
sub u0, %rdx |
| 78 |
jz L(end) |
| 79 |
|
| 80 |
ALIGN(16) |
| 81 |
L(top): rep;bsf %rdx, %rcx C tzcnt! |
| 82 |
mov u0, %rax |
| 83 |
sub v0, u0 C u - v |
| 84 |
cmovc %rdx, u0 C u = |u - v| |
| 85 |
cmovc %rax, v0 C v = min(u,v) |
| 86 |
shr R8(%rcx), u0 |
| 87 |
mov v0, %rdx |
| 88 |
sub u0, %rdx C v - u |
| 89 |
jnz L(top) |
| 90 |
|
| 91 |
L(end): mov v0, %rax |
| 92 |
C rax = result |
| 93 |
C rdx = 0 for the benefit of internal gcd_22 call |
| 94 |
FUNC_EXIT() |
| 95 |
ret |
| 96 |
EPILOGUE() |