1
Copyright 2001 Free Software Foundation, Inc.
3
This file is part of the GNU MP Library.
5
The GNU MP Library is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation; either version 2.1 of the License, or (at your
8
option) any later version.
10
The GNU MP Library is distributed in the hope that it will be useful, but
11
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13
License for more details.
15
You should have received a copy of the GNU Lesser General Public License
16
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23
INTEL PENTIUM-4 MPN SUBROUTINES
26
This directory contains mpn functions optimized for Intel Pentium-4.
28
The mmx subdirectory has routines using MMX instructions, the sse2
29
subdirectory has routines using SSE2 instructions. All P4s have these, the
30
separate directories are just so configure can omit that code if the
31
assembler doesn't support it.
38
mpn_add_n/sub_n 4 normal, 6 in-place
40
mpn_mul_1 4 normal, 6 in-place
44
mpn_mul_basecase 6 cycles/crossproduct (approx)
46
mpn_sqr_basecase 3.5 cycles/crossproduct (approx)
47
or 7.0 cycles/triangleproduct (approx)
53
The shifts ought to be able to go at 1.5 c/l, but not much effort has been
56
In-place operations, and all addmul, submul, mul_basecase and sqr_basecase
57
calls, suffer from pipeline anomalies associated with write combining and
58
movd reads and writes to the same or nearby locations. The movq
59
instructions do not trigger the same hardware problems. Unfortunately,
60
using movq and splitting/combining seems to require too many extra
61
instructions to help. Perhaps future chip steppings will be better.
67
The Pentium-4 pipeline "Netburst", provides for quite a number of surprises.
68
Many traditional x86 instructions run very slowly, requiring use of
69
alterative instructions for acceptable performance.
71
adcl and sbbl are quite slow at 8 cycles for reg->reg. paddq of 32-bits
72
within a 64-bit mmx register seems better, though the combination
73
paddq/psrlq when propagating a carry is still a 4 cycle latency.
75
incl and decl should be avoided, instead use add $1 and sub $1. Apparently
76
the carry flag is not separately renamed, so incl and decl depend on all
77
previous flags-setting instructions.
79
shll and shrl have a 4 cycle latency, or 8 times the latency of the fastest
80
integer instructions (addl, subl, orl, andl, and some more). shldl and
81
shrdl seem to have 13 and 15 cycles latency, respectively. Bizarre.
83
movq mmx -> mmx does have 6 cycle latency, as noted in the documentation.
84
pxor/por or similar combination at 2 cycles latency can be used instead.
85
The movq however executes in the float unit, thereby saving MMX execution
86
resources. With the right juggling, data moves shouldn't be on a dependent
89
L1 is write-through, but the write-combining sounds like it does enough to
90
not require explicit destination prefetching.
92
xmm registers so far haven't found a use, but not much effort has been
93
expended. A configure test for whether the operating system knows
94
fxsave/fxrestor will be needed if they're used.
100
Intel Pentium-4 processor manuals,
102
http://developer.intel.com/design/pentium4/manuals
104
"Intel Pentium 4 Processor Optimization Reference Manual", Intel, 2001,
105
order number 248966. Available on-line:
107
http://developer.intel.com/design/pentium4/manuals/248966.htm