1 dnl AMD64 mpn_lshsub_n. R
= 2^k
(U
- V
).
3 dnl Copyright
2006, 2011, 2012 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
')
35 C AMD K8,K9 3.15 (mpn_sub_n + mpn_lshift costs about 4 c/l)
36 C AMD K10 3.15 (mpn_sub_n + mpn_lshift costs about 4 c/l)
43 C This was written quickly and not optimized at all, but it runs very well on
44 C K8. But perhaps one could get under 3 c/l. Ideas:
45 C 1) Use indexing to save the 3 LEA
46 C 2) Write reasonable feed-in code
47 C 3) Be more clever about register usage
48 C 4) Unroll more, handling CL negation, carry save/restore cost much now
64 PROLOGUE(mpn_lshsub_n)
66 IFDOS(` mov 56(%rsp), %r8d ')
75 xor R32
(%rbx
), R32
(%rbx
) C clear carry save register
76 mov R32
(%r8
), R32
(%rcx
) C shift count
77 xor R32
(%r15
), R32
(%r15
) C limb carry
79 mov R32
(%rax
), R32
(%r11
)
85 add R32
(%rbx
), R32
(%rbx
) C restore carry flag
90 sbb R32
(%rbx
), R32
(%rbx
) C save carry flag
109 add R32
(%rbx
), R32
(%rbx
) C restore carry flag
126 sbb R32
(%rbx
), R32
(%rbx
) C save carry flag
142 shr R8
(%rcx
), %r15 C used next
loop