1 dnl AMD K7 mpn_modexact_1_odd
-- exact division style remainder.
3 dnl Copyright
2000-2002, 2004, 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
')
39 C mp_limb_t mpn_modexact_1_odd (mp_srcptr src, mp_size_t size,
41 C mp_limb_t mpn_modexact_1c_odd (mp_srcptr src, mp_size_t size,
42 C mp_limb_t divisor, mp_limb_t carry);
44 C With the loop running at just 11 cycles it doesn't seem worth bothering to
45 C check for
high<divisor to save one step.
47 C Using a divl for
size==1 measures slower than the modexact method
, which
48 C is
not too surprising since for the latter it
's only about 24 cycles to
49 C calculate the modular inverse.
51 defframe(PARAM_CARRY, 16)
52 defframe(PARAM_DIVISOR,12)
53 defframe(PARAM_SIZE, 8)
54 defframe(PARAM_SRC, 4)
56 defframe(SAVE_EBX, -4)
57 defframe(SAVE_ESI, -8)
58 defframe(SAVE_EDI, -12)
59 defframe(SAVE_EBP, -16)
61 deflit(STACK_SPACE, 16)
66 PROLOGUE(mpn_modexact_1c_odd)
69 movl PARAM_CARRY
, %ecx
76 PROLOGUE
(mpn_modexact_1_odd
)
81 movl PARAM_DIVISOR, %eax
82 subl $STACK_SPACE, %esp FRAME_subl_esp(STACK_SPACE)
85 movl PARAM_DIVISOR, %esi
94 LEA( binvert_limb_table
, %edi)
95 movzbl
(%eax,%edi), %edi C inv
8 bits
97 movzbl binvert_limb_table(%eax), %edi C inv 8 bits
100 xorl
%edx, %edx C initial extra carry
101 leal
(%edi,%edi), %eax C
2*inv
103 imull
%edi, %edi C inv
*inv
106 movl PARAM_SIZE
, %ebp
111 imull
%esi, %edi C inv
*inv
*d
113 subl
%edi, %eax C inv
= 2*inv
- inv
*inv
*d
114 leal
(%eax,%eax), %edi C
2*inv
116 imull
%eax, %eax C inv
*inv
118 imull
%esi, %eax C inv
*inv
*d
120 leal
(%ebx,%ebp,4), %ebx C src
end
123 subl
%eax, %edi C inv
= 2*inv
- inv
*inv
*d
125 ASSERT
(e
,` C d
*inv
== 1 mod 2^GMP_LIMB_BITS
131 C The dependent chain here is
136 C mull %esi 6 (high limb)
140 C Out of order execution hides the load latency for the source data, so no
141 C special scheduling is required.
146 C ecx next carry bit, 0 or 1 (or initial carry param)
147 C edx carry limb, high of last product
150 C ebp counter, limbs, negative
152 movl (%ebx,%ebp,4), %eax
154 subl %ecx, %eax C apply carry bit
157 setc %cl C new carry bit
159 subl %edx, %eax C apply carry limb
172 leal (%ecx,%edx), %eax
176 addl $STACK_SPACE, %esp