1 dnl AMD K7 mpn_copyi
-- copy limb vector
, incrementing.
3 dnl Copyright
1999, 2000, 2002, 2003 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
10 dnl
* the GNU Lesser General
Public License as published by the Free
11 dnl Software Foundation
; either version 3 of the License, or (at your
12 dnl option
) any later version.
16 dnl
* the GNU General
Public License as published by the Free Software
17 dnl Foundation
; either version 2 of the License, or (at your option) any
20 dnl
or both
in parallel
, as here.
22 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
23 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
24 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
27 dnl You should have received copies of the GNU General
Public License
and the
28 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
29 dnl see
https://www.gnu.
org/licenses
/.
31 include(`..
/config.m4
')
34 C alignment dst/src, A=0mod8 N=4mod8
36 C K7 0.75 1.0 1.0 0.75
39 C void mpn_copyi (mp_ptr dst, mp_srcptr src, mp_size_t size);
41 C Copy src,size to dst,size.
43 C This code at 0.75 or 1.0 c/l is always faster than a plain rep movsl at
46 C The K7 can do a 64-bit load and 64-bit store in one cycle (optimization
47 C guile 22007 appendix B), so 0.5 c/l should be possible, however nothing
48 C under 0.7 c/l is known. Apparently only two 32-bit stores can be done in
49 C one cycle, so perhaps some scheduling is needed to ensure it's a
50 C load
+store
in each cycle
, not store
+store.
52 C If both source
and destination are unaligned then one limb is processed at
53 C the start to make them aligned
and so get
0.75 c
/l
, whereas if they
'd been
54 C used unaligned it would be 1.5 c/l.
56 defframe(PARAM_SIZE,12)
57 defframe(PARAM_SRC, 8)
58 defframe(PARAM_DST, 4)
60 dnl parameter space reused
61 define(SAVE_EBX,`PARAM_SIZE')
63 dnl minimum
5 since the unrolled code can
't handle less than 5
64 deflit(UNROLL_THRESHOLD, 5)
77 cmpl $UNROLL_THRESHOLD
, %ecx
84 C
eax src
, incrementing
87 C
edx dst
, incrementing
89 C
this loop is
2 cycles
/limb
105 leal
-12(%eax,%ecx,4), %eax C src
end - 12
106 subl
$3, %ecx C
size-3
109 leal
(%edx,%ecx,4), %edx C dst
end - 12
112 testl
$4, %ebx C testl to pad code closer to
16 bytes for L
(top
)
115 C both src
and dst unaligned
, process one limb to
align them
116 movl
(%eax,%ecx,4), %ebx
117 movl
%ebx, (%edx,%ecx,4)
126 C
ecx counter
, negative
, limbs
129 movq
(%eax,%ecx,4), %mm0
130 movq
8(%eax,%ecx,4), %mm1
132 movq
%mm0
, -16(%edx,%ecx,4)
133 movq
%mm1
, -16+8(%edx,%ecx,4)
134 ja L
(top
) C jump no carry
and not zero
137 C now
%ecx is
0 to
3 representing respectively
3 to
0 limbs remaining
140 jnz L
(finish_not_two
)
142 movq
(%eax,%ecx,4), %mm0
143 movq
%mm0
, (%edx,%ecx,4)