dnl AMD K6 mpn_sqr_basecase -- square an mpn number.
dnl Copyright 1999-2002 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl TheGNU MP is software; you can redistribute it and/or modify
dnl underthe either:
dnl
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dnldnl
dnlordnl
dnl the General License published the Free Software
java.lang.StringIndexOutOfBoundsException: Range [7, 3) out of bounds for length 7
dnl
dnl MPLibrary distributed in the hope that it will be useful, but
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Librarydnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITYor FITNESS FOR A PARTICULAR . Seethe GeneralPublic License
dnlor FORAPARTICULAR PURPOSE. See the GNU General Public License
dnl dnl GNULesser General Public License withthe GNUMP . If not
dnl
dnl You should have received copies of
GNU General PublicLicense GNU MP Library If not,
dnl see https
C K6 approx4.7cycles crossproduct,or9.
C Cproduct(measured onthespeeddifferencebetween1733limbsjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
n 17and33limbsjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
is Karatsuba recursing)
dnl SQR_TOOM2_THRESHOLD_MAX dnl what it can go up to. (Anto a biggervaluewill
valueusedonlybythetune to
dnl what it can go up to.dnl
dnltrigger somem4_assert( inthe code the fail)
dnl
dnl ,giving a of 66java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
dnl a the programto configm4java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
dnl Allow a value from the tune program to override config.m4.
ifdef(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
`(`SQR_TOOM2_THRESHOLD',SQR_TOOM2_THRESHOLD_OVERRIDE)')
dnl UNROLL_COUNT is the number ed by SQR_TOOM2_THRESHOLD, since
dnl number required is determined by SQR_TOOM2_THRESHOLDdnl mpn_sqr_basecase only needs to handle sizes <SQR_TOOM2_THRESHOLD.
dnl mpn_sqr_basecase only needs to handle dnl
dnl
dnl The first addmul is the biggest, andthisdnlsignificant limb and multiplies it by the third least significant and
dnl significant limb and multiplies it by the third least significant and
up. Hence for maximummaximumoperand sizeof SQR_TOOM2_THRESHOLD-1
limbs UNROLL_COUNT needs to be SQR_TOOM2_THRESHOLD-3.
C void mpn_sqr_basecase (mp_ptr dst, java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 1
C
C The algorithm is essentially the same as mpn/generic/Clot of function calloverheads are avoided, especially when the given size
C The code sizemight look a bit excessive,but all of it is executed
C is small.
C
C The code size might look a bit excessive, but not all ofC apply only to those ; mid sizes like 10x10 only need part ofC unrolled addmul; and big sizes like 35x35 that do need all of it will
cases
C clearly apply sizes; mid sizes like 10x10 only need part of
C the unrolled addmul; and big sizes like 35x35 that do need all of it will
C at least be getting value for money, because 35x35 java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 19 5780 cycles here.
C
C Different values of UNROLL_COUNT give slightly C 9.0 and 9.2 c/tri-prod measured on the difference betwee 33limbs.
C 9.0and9.2 c/tri-prod measuredC isn' big difference, but it's presumably some alignment effect
Cjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C could give simple speedup.
defframe(PARAM_SIZE,12)
defframe(PARAM_SRC, 8)
defframe(PARAM_DST, 4dPARAM_SRC,8java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
TEXT
)
PROLOGUE(mpn_sqr_basecase)
deflit(`FRAMEPARAM_SIZE, %cx
movl PARAM_SIZE, %ecx
movl PARAM_SRC, %eax
movl PARAM_SRC, %eax je L(two_limbs)
movl java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
ja L(three_or_morejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 16
C -----------------------------------------------------------------------------
C one limb only
jaL(hree_or_more)
ebx
C ecx size
C edx dst
movl Ceax src
movl %edx, %ecx
mull %eax
movl %eax, (%ecxecx size
movl %edx, 4(%ecx)
ret
movl (eax, %ax ALIGN(16)
L(two_limbs):
C eax src
C ebx
C ecx java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
C edx dst
pushl %ebx
movl %eax, %ebx C src
deflit(`RAME',)
movl (%ebx), %eax
movl PARAM_DST, %ecx
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
movl %eax, (%ecx)
movl 4(%ebx), %eax
movl ALIGN(16java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
mullC
movl %eax, 8(%ecx)
movl (ebx),%eax
%edx, 12%ecx)
%ebx), %edx
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
movlPARAM_DST, %%ecx
adcl %dx 8(%cx
movlmovl%ax,(ecx)
popl %bx
addl %eax, 4(%ecx)
adcl %edx,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
adcl $0, 12(%ecx)
ret
C ------------------------java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Lthree_or_more):
deflit(`FRAME',0)
cmpl $4, %ecx
jae L movl (ebx, %
C --- movl %edx, 12(%ecx)
C three limbs
C eax src
C ecx size
C edx dst
pushljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
movl %eax, %bx src
movl (%ebx), %eax
movl %edx, %ecx C dst
mull eax C [0]^2
movl % adcl %edx %dx 8%ecx)
ovl 4(ebx), %ax
movl %edx, 4(%ecx)
pushl %esi
java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
$ 12(e)
movl %edx, 12(%ecx)
C -----------------------------------------
mull %eax C src[2]L(hree_or_more)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
movl %eax, 16(%ecx) jae L(four_or_more)
C ------------------------------------------------------
movl%edx, 20(%ecx)
movl 4(%ebx), %edx
mull %edx C src[0] * src[1]
movl %eax, %esi
movl (%ebx), %eax
C ec size
C dst
%
xorl %, %ebx src
movl %ebx), e
addle,%edi
mulleax C src[0]^2
adcl %edx, %ebp
movl 8 %ax (%)
mull %edx C src[1] * src movl 4(ebx,%
addl %eax, %ebp
adcl $
C eax will be dst[5]
C ebx
C ecx dst
C edx dst[4]
C esi dst[1]
C edi dst[2]
C ebp dst[3]
%bp
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
e,16%cx)
popl % C [0] *src[1]
popl %ebx
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
ASSERT(c
ret
C -------movl 8(ebx) %edx
(SAVE_EBX 4)
ameS, -8)
defframe(SAVE_EDI, -12)
defframe(SAVE_EBP, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [26, 8) out of bounds for length 25
defframe(movl 4(ebx) e
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ALIGN(16)
L(four_or_more):
mull%dx src[1 *[]
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C size
Cjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
esi
C edi
ebp
C First multiply src[0]*java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 10
C
as done calling here getthe of itsunrollededi2]
C e, % 5780cycle operation,whichis not surprising the loophere is 8
C/l andmpn_mul_1 is 625c/java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
subl adcl $0,%eax
movl % addl%si,4(%ecxjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
leal 4(edx), %di
movl %ebx, SAVE_EBX 4%eax) %ebx
e
popl %di
movl%, SAVE_EBP
C eax
C ebx src+4
C ecx size
C edx
C java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C adcl %ax 20%)
movl (%eax), %ebp C multiplier 1(ecx,%cx size-1and padto a 16 boundary
ALIGN ret
Ljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C scratch
ptr
C defframe(AVE_ESI -)
(SAVE_EDI, -2)
C esi carry
C edi dst ptr
defframe, 16)
movl (%ebx), %eax
addl $4, %defframe(VAR_C,20)
mull %ebp
%,%eax
movl
adcl %L(four_or_more):
movl %eax ebx edi
loop L(mul_1)
C esi
C
C java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
C ,are .Theseare src[ize-3]src[-2,ize-]
C and src[size-2]*src[size-1]. If size is 4 thenC
cases to be .
C
The unrolled codeis as mpn_addmul_1(,see routine some
C .
C
C C cl mpn_mul_1is6. /l
C
C VAR_JMPjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C chunk eachouterloop.
C
java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
ually it'a each time. unrolled addmul
C java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C the
dnl This value is Cecx
dnl
(CODE_BYTES_PER_LIMB, 15)
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
valuesup 31. that an offset must be added them.
dnl
deflit(,
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
eval(UNROLL_COUNT31*) 0))
eax
C ebx &src[size]
C ecxCecx counter
C edx carry
C edi &C ebp multiplier
java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0
movl PARAM_SIZE, %ecx
mull%
subl% e jz(corner)
, %dx
ifelse
`sublO,%bx'java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
shll
ifelse(OFFSET,0,,
` subl $OFFSET, %edi')
negl %ecx
ifdef(`PIC',`
CThe lasttwoaddmuls which are bottomright ofthe product
L(here):C , are leftto the .These [ize3*s-,ize-] 'and [size2*s-1].Ifsize ' only corner
L(nroll_inner_endeval2CODE_BYTES_PER_LIMB)%,edx), ecx ')
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
C The calculated jump mustnC commentsjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 code. This thelimitation UNROLL_COUNT puts on the src operand
C size, but checked here using the jump address directly.
C
ASSERT(ae,`
C chunkeach outer loop.
cmpl %CK6 doesn't do branch prediction on indirect jumps, which is good ')
C C is 3 cycles/limb faster than asimpleloop, so the cyclecost of ALIGN(16)
L(unroll_outer_top):
C eax
C ebx &src[size], constant
C ecx VAR_JMP
C edx VAR_COUNTER, limbs, C the indirectjump quickly .
Cdnl value alsoimplicitly ashift add
C edideflit(ODE_BYTES_PER_LIMB15java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
C ebp
dnl valuesup 31Above that anoffset addedto .
movl %edx, VAR_COUNTER
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
mull %ebp
testb $1,eval(-31)4,
movl%edx,%Chigh carry
movl %ecx, %edx C jump
movl
lealCODE_BYTES_PER_LIMB(%edx), %edx
movl %edx, VAR_JMP
leal 4(%edi), %edi
C A branch-free version of this using some xors was found to java.lang.StringIndexOutOfBoundsException: Range [0, 64) out of bounds for length 6
touch slower just a conditional jump,despite the jump
switching taken taken on every.
jz Lcorner)
movl esi% C high,lowcarryotherwayaround
movl %ecx, %esi
movl %eax, %ecx
L():
jmp *%edx
C java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
Cwill which way around ecx/si should start.
java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
attempt made at here to get endof the
n %cx
C L(corner). This worked, but turned out to run slower than just
CALIGN() Thereason thisis clear, it be related
C thedifferentspeedson UNROLL_COUNTs abovejava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
ALIGN(2)
L(java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 2
C eax java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
C ebx src
C ecxcarry low
C scratch
C esi carry high
C edi dst
C ebp multiplier
C
C 15code bytes each java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0
deflit(disp_src'eval(i4+OFFSET)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
deflit(disp_dst' ( - 4)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
,0,java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
, %eax)
mull %ebp
Zdisp( addl, %esi, disp_dst,(%edi))
adcl %eax, %ecx
movl %edx, %esi
jadcl0( %esi) ',`
dnl this one comes out last
Zdisp(
mull %ebp
Zdisp( addl, %ecx, disp_dst,(%edi))
adcl %eax movl %edx, VAR_COUNTER
movl %edx, %ecx
jadcl0( OFFSET%ebx,%dx4, % Cfirstlimbof multiplicand ')
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 2
L():
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C----------------------------------------------- ALIGN(16)
L(corner):
*edx
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
movl -12(%ebx), %ebp
-(ebx)%ax
movl attempt was made java.lang.StringIndexOutOfBoundsException: Range [41, 38) out of bounds for length 69
mull %ebp
addl %eax, -4(%edi)
adcl $0,%edx
-%) eax
movl %java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
%ax,%ebx
mull %ebp
addl%si,%
edx
C edi dst
adcl $0, %edx
movl e,%si
movl % C 15 code15 each
mull %ecx
addl %esi, %eax
movlforloop`' , 1 java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
adcl 0 edx
m4_assert`isp_src>-128& disp_src<28'
C --ifelse(val(i2)0`
C Left shift of dst[1( movl, ,%),%)
C Zdisp(addl,%si,disp_dst,%)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
C decode jadcl0( %e( %java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
L(Zdispmovl, (ebx), eaxjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
movl PARAM_SIZE, %cx
movl PARAM_DSTi %ax, e
movl %,%cx
movl java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2
movl %ecx, %edx
xorl%ax,% ready adcl
ALIGN(16)
L(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
C eax
ebxsrc(or use)
C ecx %ecx, m4_empty_if_zero)%dijava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
i %edx
esi
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
a $OFFSET,e
java.lang.StringIndexOutOfBoundsException: Range [1, 5) out of bounds for length 2
rcll8(%di)
leal 8(edi,%
loop LL()java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
adcl %eax,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
movl -8(ebx) eax
movl %) eax C [0]
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
subl %adcl $0,edx
-------------------------------------------
C Now add in e,%si
C srcjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
low of src[0^.
mull %eax
% %,ecx8 [java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
ALIGN(16 e,esi
L(diag
C eax scratch
]
C ecx movl%eax,4(edijava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
C edx carry
C esi scratch
C edi java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C ebp
C The measuresabout6cyclesiteration lookslike
movl %dx,esi
subl$1, ecx C size- and clear carry jnz L(diag movl PARAM_SRC %
xorl%ax,%eax readyfor adcl
movl SAVE_ESI, %esi
addl %edx,
E_EDI %di
movl SAVE_EBP,Llshift:
addl $FRAME, %esp
ret
C ------------ C ecxcounter, decrementing ifdef(`PIC',`
L(pic_calc):
Seempnx86README about old gas bugs
addl (%esp), %ecx
addl $L C esi
addl %edx, %ecx
ret_internal ')
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.