xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/x86_64/copyd.asm (revision 1897181a7231d5fc7ab48994d1447fcbc4e13a49)
1dnl  AMD64 mpn_copyd -- copy limb vector, decrementing.
2
3dnl  Copyright 2003, 2005, 2007 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of the GNU Lesser General Public License as published
9dnl  by the Free Software Foundation; either version 3 of the License, or (at
10dnl  your option) any later version.
11
12dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15dnl  License for more details.
16
17dnl  You should have received a copy of the GNU Lesser General Public License
18dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20include(`../config.m4')
21
22
23C	    cycles/limb
24C K8,K9:	1
25C K10:		1
26C P4:		2.8
27C P6 core2:	1.2
28C P6 corei7:	1
29
30
31C INPUT PARAMETERS
32C rp	rdi
33C up	rsi
34C n	rdx
35
36define(`rp',`%rdi')
37define(`up',`%rsi')
38define(`n',`%rdx')
39
40ASM_START()
41	TEXT
42	ALIGN(16)
43PROLOGUE(mpn_copyd)
44	leaq	-8(up,n,8), up
45	leaq	(rp,n,8), rp
46	subq	$4, n
47	jc	L(end)
48	ALIGN(16)
49L(oop):	movq	(up), %r8
50	movq	-8(up), %r9
51	leaq	-32(rp), rp
52	movq	-16(up), %r10
53	movq	-24(up), %r11
54	leaq	-32(up), up
55	movq	%r8, 24(rp)
56	movq	%r9, 16(rp)
57	subq	$4, n
58	movq	%r10, 8(rp)
59	movq	%r11, (rp)
60	jnc	L(oop)
61
62L(end):	shrl	%edx			C edx = lowpart(n)
63	jnc	1f
64	movq	(up), %r8
65	movq	%r8, -8(rp)
66	leaq	-8(rp), rp
67	leaq	-8(up), up
681:	shrl	%edx			C edx = lowpart(n)
69	jnc	1f
70	movq	(up), %r8
71	movq	-8(up), %r9
72	movq	%r8, -8(rp)
73	movq	%r9, -16(rp)
741:	ret
75EPILOGUE()
76