aboutsummaryrefslogtreecommitdiff
path: root/vendor/gmp-6.3.0/mpn/alpha/ev67
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gmp-6.3.0/mpn/alpha/ev67')
-rw-r--r--vendor/gmp-6.3.0/mpn/alpha/ev67/gcd_11.asm79
-rw-r--r--vendor/gmp-6.3.0/mpn/alpha/ev67/hamdist.asm111
-rw-r--r--vendor/gmp-6.3.0/mpn/alpha/ev67/popcount.asm101
3 files changed, 291 insertions, 0 deletions
diff --git a/vendor/gmp-6.3.0/mpn/alpha/ev67/gcd_11.asm b/vendor/gmp-6.3.0/mpn/alpha/ev67/gcd_11.asm
new file mode 100644
index 0000000..03c234b
--- /dev/null
+++ b/vendor/gmp-6.3.0/mpn/alpha/ev67/gcd_11.asm
@@ -0,0 +1,79 @@
+dnl Alpha ev67 mpn_gcd_11 -- Nx1 greatest common divisor.
+
+dnl Copyright 2003, 2004 Free Software Foundation, Inc.
+
+dnl This file is part of the GNU MP Library.
+dnl
+dnl The GNU MP Library is free software; you can redistribute it and/or modify
+dnl it under the terms of either:
+dnl
+dnl * the GNU Lesser General Public License as published by the Free
+dnl Software Foundation; either version 3 of the License, or (at your
+dnl option) any later version.
+dnl
+dnl or
+dnl
+dnl * the GNU General Public License as published by the Free Software
+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 Library is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+dnl for more details.
+dnl
+dnl You should have received copies of the GNU General Public License and the
+dnl GNU Lesser General Public License along with the GNU MP Library. If not,
+dnl see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+
+C ev67: 3.4 cycles/bitpair for 1x1 part
+
+
+C mp_limb_t mpn_gcd_1 (mp_srcptr xp, mp_size_t xsize, mp_limb_t y);
+C
+C In the 1x1 part, the algorithm is to change x,y to abs(x-y),min(x,y) and
+C strip trailing zeros from abs(x-y) to maintain x and y both odd.
+C
+C The trailing zeros are calculated from just x-y, since in twos-complement
+C there's the same number of trailing zeros on d or -d. This means the cttz
+C runs in parallel with abs(x-y).
+C
+C The loop takes 5 cycles, and at 0.68 iterations per bit for two N-bit
+C operands with this algorithm gives the measured 3.4 c/l.
+C
+C The slottings shown are for SVR4 style systems, Unicos differs in the
+C initial gp setup and the LEA.
+
+
+ASM_START()
+PROLOGUE(mpn_gcd_11)
+ mov r16, r0
+ mov r17, r1
+
+ ALIGN(16)
+L(top): subq r0, r1, r7 C l0 d = x - y
+ cmpult r0, r1, r16 C u0 test x >= y
+
+ subq r1, r0, r4 C l0 new_x = y - x
+ cttz r7, r8 C U0 d twos
+
+ cmoveq r16, r7, r4 C l0 new_x = d if x>=y
+ cmovne r16, r0, r1 C u0 y = x if x<y
+ unop C l \ force cmoveq into l0
+ unop C u /
+
+ C C cmoveq2 L0, cmovne2 U0
+
+ srl r4, r8, r0 C U0 x = new_x >> twos
+ bne r7, L(top) C U1 stop when d==0
+
+
+L(end): mov r1, r0 C U0 return y << common_twos
+ ret r31, (r26), 1 C L0
+EPILOGUE()
+ASM_END()
diff --git a/vendor/gmp-6.3.0/mpn/alpha/ev67/hamdist.asm b/vendor/gmp-6.3.0/mpn/alpha/ev67/hamdist.asm
new file mode 100644
index 0000000..4b13e9f
--- /dev/null
+++ b/vendor/gmp-6.3.0/mpn/alpha/ev67/hamdist.asm
@@ -0,0 +1,111 @@
+dnl Alpha ev67 mpn_hamdist -- mpn hamming distance.
+
+dnl Copyright 2003, 2005 Free Software Foundation, Inc.
+
+dnl This file is part of the GNU MP Library.
+dnl
+dnl The GNU MP Library is free software; you can redistribute it and/or modify
+dnl it under the terms of either:
+dnl
+dnl * the GNU Lesser General Public License as published by the Free
+dnl Software Foundation; either version 3 of the License, or (at your
+dnl option) any later version.
+dnl
+dnl or
+dnl
+dnl * the GNU General Public License as published by the Free Software
+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 Library is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+dnl for more details.
+dnl
+dnl You should have received copies of the GNU General Public License and the
+dnl GNU Lesser General Public License along with the GNU MP Library. If not,
+dnl see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+
+C ev67: 2.5 cycles/limb
+
+
+C unsigned long mpn_hamdist (mp_srcptr xp, mp_srcptr yp, mp_size_t size);
+C
+C The hope was for 2.0 c/l here, but that isn't achieved. We're limited by
+C renaming register shortage. Since we need 5 instructions per limb, further
+C unrolling could approach 1.5 c/l.
+C
+C The main loop processes two limbs from each operand on each iteration. An
+C odd size is handled by processing xp[0]^yp[0] at the start. If the size
+C is even that result is discarded, and is repeated by the main loop.
+C
+
+ASM_START()
+PROLOGUE(mpn_hamdist)
+
+ C r16 xp
+ C r17 yp
+ C r18 size
+
+ ldq r1, 0(r16) C L0 xp[0]
+ ldq r2, 0(r17) C L1 yp[0]
+ and r18, 1, r8 C U1 1 if size odd
+ srl r18, 1, r18 C U0 size, limb pairs
+
+ clr r0 C L0 initial total
+ s8addq r8, r17, r17 C U1 yp++ if size odd
+ s8addq r8, r16, r16 C L1 xp++ if size odd
+ clr r6 C U0 dummy initial xor 1
+
+ xor r1, r2, r5 C L initial xor 0
+ beq r18, L(one) C U if size==1
+
+ cmoveq r8, r31, r5 C L discard first limb if size even
+ unop C U
+
+
+ ALIGN(16)
+L(top):
+ C r0 total accumulating
+ C r7 xor 0
+ C r8 xor 1
+ C r16 xp, incrementing
+ C r17 yp, incrementing
+ C r18 size, limb pairs, decrementing
+
+ ldq r1, 0(r16) C L
+ ldq r2, 0(r17) C L
+ ctpop r5, r7 C U0
+ lda r16, 16(r16) C U
+
+ ldq r3, -8(r16) C L
+ ldq r4, 8(r17) C L
+ ctpop r6, r8 C U0
+ lda r17, 16(r17) C U
+
+ ldl r31, 256(r16) C L prefetch
+ ldl r31, 256(r17) C L prefetch
+ xor r1, r2, r5 C U
+ lda r18, -1(r18) C U
+
+ xor r3, r4, r6 C U
+ addq r0, r7, r0 C L
+ addq r0, r8, r0 C L
+ bne r18, L(top) C U
+
+
+ ctpop r6, r8 C U0
+ addq r0, r8, r0 C L
+L(one):
+ ctpop r5, r7 C U0
+ addq r0, r7, r0 C L
+
+ ret r31, (r26), 1 C L0
+
+EPILOGUE()
+ASM_END()
diff --git a/vendor/gmp-6.3.0/mpn/alpha/ev67/popcount.asm b/vendor/gmp-6.3.0/mpn/alpha/ev67/popcount.asm
new file mode 100644
index 0000000..049c1cd
--- /dev/null
+++ b/vendor/gmp-6.3.0/mpn/alpha/ev67/popcount.asm
@@ -0,0 +1,101 @@
+dnl Alpha ev67 mpn_popcount -- mpn bit population count.
+
+dnl Copyright 2003, 2005 Free Software Foundation, Inc.
+
+dnl This file is part of the GNU MP Library.
+dnl
+dnl The GNU MP Library is free software; you can redistribute it and/or modify
+dnl it under the terms of either:
+dnl
+dnl * the GNU Lesser General Public License as published by the Free
+dnl Software Foundation; either version 3 of the License, or (at your
+dnl option) any later version.
+dnl
+dnl or
+dnl
+dnl * the GNU General Public License as published by the Free Software
+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 Library is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+dnl for more details.
+dnl
+dnl You should have received copies of the GNU General Public License and the
+dnl GNU Lesser General Public License along with the GNU MP Library. If not,
+dnl see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+
+C ev67: 1.5 cycles/limb
+
+
+C unsigned long mpn_popcount (mp_srcptr src, mp_size_t size);
+C
+C This schedule seems necessary for the full 1.5 c/l, the IQ can't quite hide
+C all latencies, the addq's must be deferred to the next iteration.
+C
+C Since we need just 3 instructions per limb, further unrolling could approach
+C 1.0 c/l.
+C
+C The main loop processes two limbs at a time. An odd size is handled by
+C processing src[0] at the start. If the size is even that result is
+C discarded, and src[0] is repeated by the main loop.
+C
+
+ASM_START()
+PROLOGUE(mpn_popcount)
+
+ C r16 src
+ C r17 size
+
+ ldq r0, 0(r16) C L0 src[0]
+ and r17, 1, r8 C U1 1 if size odd
+ srl r17, 1, r17 C U0 size, limb pairs
+
+ s8addq r8, r16, r16 C L1 src++ if size odd
+ ctpop r0, r0 C U0
+ beq r17, L(one) C U1 if size==1
+
+ cmoveq r8, r31, r0 C L discard first limb if size even
+ clr r3 C L
+
+ clr r4 C L
+ unop C U
+ unop C L
+ unop C U
+
+
+ ALIGN(16)
+L(top):
+ C r0 total accumulating
+ C r3 pop 0
+ C r4 pop 1
+ C r16 src, incrementing
+ C r17 size, decrementing
+
+ ldq r1, 0(r16) C L
+ ldq r2, 8(r16) C L
+ lda r16, 16(r16) C U
+ lda r17, -1(r17) C U
+
+ addq r0, r3, r0 C L
+ addq r0, r4, r0 C L
+ ctpop r1, r3 C U0
+ ctpop r2, r4 C U0
+
+ ldl r31, 512(r16) C L prefetch
+ bne r17, L(top) C U
+
+
+ addq r0, r3, r0 C L
+ addq r0, r4, r0 C U
+L(one):
+ ret r31, (r26), 1 C L0
+
+EPILOGUE()
+ASM_END()