|
Packit |
5c3484 |
dnl AMD64 mpn_invert_limb -- Invert a normalized limb.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl Contributed to the GNU project by Torbjorn Granlund and Niels Möller.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl Copyright 2004, 2007-2009, 2011, 2012 Free Software Foundation, Inc.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl This file is part of the GNU MP Library.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl The GNU MP Library is free software; you can redistribute it and/or modify
|
|
Packit |
5c3484 |
dnl it under the terms of either:
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl * the GNU Lesser General Public License as published by the Free
|
|
Packit |
5c3484 |
dnl Software Foundation; either version 3 of the License, or (at your
|
|
Packit |
5c3484 |
dnl option) any later version.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl or
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl * the GNU General Public License as published by the Free Software
|
|
Packit |
5c3484 |
dnl Foundation; either version 2 of the License, or (at your option) any
|
|
Packit |
5c3484 |
dnl later version.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl or both in parallel, as here.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl The GNU MP Library is distributed in the hope that it will be useful, but
|
|
Packit |
5c3484 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
5c3484 |
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
5c3484 |
dnl for more details.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl You should have received copies of the GNU General Public License and the
|
|
Packit |
5c3484 |
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
|
|
Packit |
5c3484 |
dnl see https://www.gnu.org/licenses/.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
include(`../config.m4')
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C cycles/limb (approx) div
|
|
Packit |
5c3484 |
C AMD K8,K9 48 71
|
|
Packit |
5c3484 |
C AMD K10 48 77
|
|
Packit |
5c3484 |
C Intel P4 135 161
|
|
Packit |
5c3484 |
C Intel core2 69 116
|
|
Packit |
5c3484 |
C Intel corei 55 89
|
|
Packit |
5c3484 |
C Intel atom 129 191
|
|
Packit |
5c3484 |
C VIA nano 79 157
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C rax rcx rdx rdi rsi r8
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
ABI_SUPPORT(DOS64)
|
|
Packit |
5c3484 |
ABI_SUPPORT(STD64)
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
PROTECT(`mpn_invert_limb_table')
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
ASM_START()
|
|
Packit |
5c3484 |
TEXT
|
|
Packit |
5c3484 |
ALIGN(16)
|
|
Packit |
5c3484 |
PROLOGUE(mpn_invert_limb) C Kn C2 Ci
|
|
Packit |
5c3484 |
FUNC_ENTRY(1)
|
|
Packit |
5c3484 |
mov %rdi, %rax C 0 0 0
|
|
Packit |
5c3484 |
shr $55, %rax C 1 1 1
|
|
Packit |
5c3484 |
ifdef(`PIC',`
|
|
Packit |
5c3484 |
ifdef(`DARWIN',`
|
|
Packit |
5c3484 |
mov mpn_invert_limb_table@GOTPCREL(%rip), %r8
|
|
Packit |
5c3484 |
add $-512, %r8
|
|
Packit |
5c3484 |
',`
|
|
Packit |
5c3484 |
lea -512+mpn_invert_limb_table(%rip), %r8
|
|
Packit |
5c3484 |
')',`
|
|
Packit |
5c3484 |
movabs $-512+mpn_invert_limb_table, %r8
|
|
Packit |
5c3484 |
')
|
|
Packit |
5c3484 |
movzwl (%r8,%rax,2), R32(%rcx) C %rcx = v0
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C v1 = (v0 << 11) - (v0*v0*d40 >> 40) - 1
|
|
Packit |
5c3484 |
mov %rdi, %rsi C 0 0 0
|
|
Packit |
5c3484 |
mov R32(%rcx), R32(%rax) C 4 5 5
|
|
Packit |
5c3484 |
imul R32(%rcx), R32(%rcx) C 4 5 5
|
|
Packit |
5c3484 |
shr $24, %rsi C 1 1 1
|
|
Packit |
5c3484 |
inc %rsi C %rsi = d40
|
|
Packit |
5c3484 |
imul %rsi, %rcx C 8 10 8
|
|
Packit |
5c3484 |
shr $40, %rcx C 12 15 11
|
|
Packit |
5c3484 |
sal $11, R32(%rax) C 5 6 6
|
|
Packit |
5c3484 |
dec R32(%rax)
|
|
Packit |
5c3484 |
sub R32(%rcx), R32(%rax) C %rax = v1
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C v2 = (v1 << 13) + (v1 * (2^60 - v1*d40) >> 47)
|
|
Packit |
5c3484 |
mov $0x1000000000000000, %rcx
|
|
Packit |
5c3484 |
imul %rax, %rsi C 14 17 13
|
|
Packit |
5c3484 |
sub %rsi, %rcx
|
|
Packit |
5c3484 |
imul %rax, %rcx
|
|
Packit |
5c3484 |
sal $13, %rax
|
|
Packit |
5c3484 |
shr $47, %rcx
|
|
Packit |
5c3484 |
add %rax, %rcx C %rcx = v2
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C v3 = (v2 << 31) + (v2 * (2^96 - v2 * d63 + ((v2 >> 1) & mask)) >> 65
|
|
Packit |
5c3484 |
mov %rdi, %rsi C 0 0 0
|
|
Packit |
5c3484 |
shr %rsi C d/2
|
|
Packit |
5c3484 |
sbb %rax, %rax C -d0 = -(d mod 2)
|
|
Packit |
5c3484 |
sub %rax, %rsi C d63 = ceil(d/2)
|
|
Packit |
5c3484 |
imul %rcx, %rsi C v2 * d63
|
|
Packit |
5c3484 |
and %rcx, %rax C v2 * d0
|
|
Packit |
5c3484 |
shr %rax C (v2>>1) * d0
|
|
Packit |
5c3484 |
sub %rsi, %rax C (v2>>1) * d0 - v2 * d63
|
|
Packit |
5c3484 |
mul %rcx
|
|
Packit |
5c3484 |
sal $31, %rcx
|
|
Packit |
5c3484 |
shr %rdx
|
|
Packit |
5c3484 |
add %rdx, %rcx C %rcx = v3
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
mov %rdi, %rax
|
|
Packit |
5c3484 |
mul %rcx
|
|
Packit |
5c3484 |
add %rdi, %rax
|
|
Packit |
5c3484 |
mov %rcx, %rax
|
|
Packit |
5c3484 |
adc %rdi, %rdx
|
|
Packit |
5c3484 |
sub %rdx, %rax
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
FUNC_EXIT()
|
|
Packit |
5c3484 |
ret
|
|
Packit |
5c3484 |
EPILOGUE()
|
|
Packit |
5c3484 |
ASM_END()
|
|
rpm-build |
c3cd4f |
CF_PROT
|