1 dnl x86
-32 mpn_mod_1s_4p for Pentium
4 and P6 models with SSE2
(i.e.
9,D
,E
,F
).
3 dnl Contributed to the GNU project by Torbjorn Granlund.
5 dnl Copyright
2009, 2010 Free Software Foundation
, Inc.
7 dnl
This file is part of the GNU MP Library.
9 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
10 dnl it under the terms of
either:
12 dnl
* the GNU Lesser General
Public License as published by the Free
13 dnl Software Foundation
; either version 3 of the License, or (at your
14 dnl option
) any later version.
18 dnl
* the GNU General
Public License as published by the Free Software
19 dnl Foundation
; either version 2 of the License, or (at your option) any
22 dnl
or both
in parallel
, as here.
24 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
25 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
26 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
29 dnl You should have received copies of the GNU General
Public License
and the
30 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
31 dnl see
https://www.gnu.
org/licenses
/.
33 include(`..
/config.m4
')
36 C * Optimize. The present code was written quite straightforwardly.
37 C * Optimize post-loop reduction code.
38 C * Write a cps function that uses sse2 insns.
41 C P6 model 0-8,10-12 -
42 C P6 model 9 (Banias) ?
43 C P6 model 13 (Dothan) 3.4
44 C P4 model 0-1 (Willamette) ?
45 C P4 model 2 (Northwood) 4
46 C P4 model 3-4 (Prescott) 4.5
54 define(`B1modb', `
%mm1
')
55 define(`B2modb', `
%mm2
')
56 define(`B3modb', `
%mm3
')
57 define(`B4modb', `
%mm4
')
58 define(`B5modb', `
%mm5
')
65 PROLOGUE(mpn_mod_1s_4p)
85 L(b3): movd -4(ap), %mm7
97 L(b0): movd -8(ap), %mm7
112 L(b1): movd (ap), %mm7
118 L(b2): movd -4(ap), %mm7 C rl
119 punpckldq (ap), %mm7 C rh
125 L(top): movd 4(ap), %mm0
150 L(end): pcmpeqd %mm4, %mm4
151 psrlq $32, %mm4 C 0x00000000FFFFFFFF
154 pmuludq B1modb, %mm7 C rh,cl
155 paddq %mm4, %mm7 C rh,rl
156 L(x): movd 4(%ecx), %mm4 C cnt
157 psllq %mm4, %mm7 C rh,rl normalized
158 movq %mm7, %mm2 C rl in low half
160 movd (%ecx), %mm1 C bi
161 pmuludq %mm7, %mm1 C qh,ql
162 paddq %mm2, %mm1 C qh-1,ql
164 psrlq $32, %mm1 C qh-1
165 movd 16(%esp), %mm3 C b
166 pmuludq %mm1, %mm3 C (qh-1) * b
167 psubq %mm3, %mm2 C r in low half (could use psubd)
172 lea (%eax,%ebx), %edx
174 movd %mm4, %ecx C cnt
182 L(fix): sub %ebx, %eax
190 PROLOGUE(mpn_mod_1s_4p_cps)
191 C CAUTION: This is the same code as in k7/mod_1_4.asm
196 mov 20(%esp), %ebp C FIXME: avoid bp for 0-idx
200 sal %cl, %ebx C b << cnt
208 mov %eax, (%ebp) C store bi
209 mov %ecx, 4(%ebp) C store cnt
217 mov %esi, 8(%ebp) C store B1modb
221 lea (%edx,%ebx), %esi
229 mov %esi, 12(%ebp) C store B2modb
233 lea (%edx,%ebx), %esi
241 mov %esi, 16(%ebp) C store B3modb
245 lea (%edx,%ebx), %esi
253 mov %esi, 20(%ebp) C store B4modb
262 mov %ebx, 24(%ebp) C store B5modb