1 dnl Intel P6 mpn_modexact_1_odd
-- exact division style remainder.
3 dnl Copyright
2000-2002, 2007 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 P6: 10.0 cycles/limb
37 C mp_limb_t mpn_modexact_1_odd (mp_srcptr src, mp_size_t size,
39 C mp_limb_t mpn_modexact_1c_odd (mp_srcptr src, mp_size_t size,
40 C mp_limb_t divisor, mp_limb_t carry);
42 C It's
not worth skipping a step at the
end when
high<divisor since the main
43 C
loop is only
10 cycles.
45 defframe
(PARAM_CARRY
, 16)
46 defframe
(PARAM_DIVISOR
,12)
47 defframe
(PARAM_SIZE
, 8)
48 defframe
(PARAM_SRC
, 4)
50 dnl
Not enough room under modexact_1 to make these re
-use the parameter
51 dnl space
, unfortunately.
52 defframe
(SAVE_EBX
, -4)
53 defframe
(SAVE_ESI
, -8)
54 defframe
(SAVE_EDI
, -12)
55 deflit
(STACK_SPACE
, 12)
60 PROLOGUE
(mpn_modexact_1c_odd
)
63 movl PARAM_CARRY, %ecx
69 PROLOGUE(mpn_modexact_1_odd)
74 movl PARAM_DIVISOR
, %eax
76 subl $STACK_SPACE
, %esp FRAME_subl_esp
(STACK_SPACE
)
87 LEA( binvert_limb_table, %edi)
88 movzbl (%eax,%edi), %edi C inv 8 bits
90 movzbl binvert_limb_table
(%eax), %edi C inv
8 bits
93 xorl %edx, %edx C initial extra carry
94 leal (%edi,%edi), %eax C 2*inv
96 imull %edi, %edi C inv*inv
101 imull PARAM_DIVISOR, %edi C inv*inv*d
103 subl %edi, %eax C inv = 2*inv - inv*inv*d
104 leal (%eax,%eax), %edi C 2*inv
106 imull %eax, %eax C inv*inv
108 imull PARAM_DIVISOR, %eax C inv*inv*d
110 leal (%esi,%ebx,4), %esi C src end
113 subl %eax, %edi C inv = 2*inv - inv*inv*d
115 ASSERT(e,` C d*inv == 1 mod 2^GMP_LIMB_BITS
116 movl PARAM_DIVISOR, %eax
121 C The dependent chain here is
125 C mull PARAM_DIVISOR
5
129 C
and this is the measured speed. No special scheduling is necessary
, out
130 C of order execution hides the load latency.
133 C
eax scratch
(src limb
)
134 C
ebx counter
, limbs
, negative
135 C
ecx carry bit
, 0 or 1
136 C
edx carry limb
, high of last product
141 movl
(%esi,%ebx,4), %eax
160 leal
(%ecx,%edx), %eax
165 addl $STACK_SPACE
, %esp