diff options
Diffstat (limited to 'gmp/mpn/s390_64')
-rw-r--r-- | gmp/mpn/s390_64/README | 88 | ||||
-rw-r--r-- | gmp/mpn/s390_64/addmul_1.asm | 72 | ||||
-rw-r--r-- | gmp/mpn/s390_64/aorrlsh1_n.asm | 168 | ||||
-rw-r--r-- | gmp/mpn/s390_64/aors_n.asm | 136 | ||||
-rw-r--r-- | gmp/mpn/s390_64/bdiv_dbm1c.asm | 65 | ||||
-rw-r--r-- | gmp/mpn/s390_64/copyd.asm | 144 | ||||
-rw-r--r-- | gmp/mpn/s390_64/copyi.asm | 68 | ||||
-rw-r--r-- | gmp/mpn/s390_64/gmp-mparam.h | 175 | ||||
-rw-r--r-- | gmp/mpn/s390_64/invert_limb.asm | 94 | ||||
-rw-r--r-- | gmp/mpn/s390_64/logops_n.asm | 291 | ||||
-rw-r--r-- | gmp/mpn/s390_64/lshift.asm | 196 | ||||
-rw-r--r-- | gmp/mpn/s390_64/lshiftc.asm | 207 | ||||
-rw-r--r-- | gmp/mpn/s390_64/mod_34lsub1.asm | 109 | ||||
-rw-r--r-- | gmp/mpn/s390_64/mul_1.asm | 66 | ||||
-rw-r--r-- | gmp/mpn/s390_64/mul_basecase.asm | 130 | ||||
-rw-r--r-- | gmp/mpn/s390_64/rshift.asm | 195 | ||||
-rw-r--r-- | gmp/mpn/s390_64/sqr_basecase.asm | 203 | ||||
-rw-r--r-- | gmp/mpn/s390_64/sublsh1_n.asm | 169 | ||||
-rw-r--r-- | gmp/mpn/s390_64/submul_1.asm | 70 | ||||
-rw-r--r-- | gmp/mpn/s390_64/z10/gmp-mparam.h | 231 |
20 files changed, 2877 insertions, 0 deletions
diff --git a/gmp/mpn/s390_64/README b/gmp/mpn/s390_64/README new file mode 100644 index 0000000000..8f482a9cd2 --- /dev/null +++ b/gmp/mpn/s390_64/README @@ -0,0 +1,88 @@ +Copyright 2011 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. + + + +There are 5 generations of 64-but s390 processors, z900, z990, z9, +z10, and z196. The current GMP code was optimised for the two oldest, +z900 and z990. + + +mpn_copyi + +This code makes use of a loop around MVC. It almost surely runs very +close to optimally. A small improvement could be done by using one +MVC for size 256 bytes, now we use two (we use an extra MVC when +copying any multiple of 256 bytes). + + +mpn_copyd + +We have tried several feed-in variants here, branch tree, jump table +and computed goto. The fastest (on z990) turned out to be computed +goto. + +An approach not tried is EX of LMG and STMG, modifying the register set +on-the-fly. Using that trick, we could completely avoid using +separate feed-in paths. + + +mpn_lshift, mpn_rshift + +The current code runs at pipeline decode bandwith on z990. + + +mpn_add_n, mpn_sub_n + +The current code is 4-way unrolled. It should be unrolled more, at +least 8x, in order to reach 2.5 c/l. + + +mpn_mul_1, mpn_addmul_1, mpn_submul_1 + +The current code is very naive, but due to the non-pipelined nature of +MLGR on z900 and z990, more sophisticated code would not gain much. + +On z10 one would need to cluster at least 4 MLGR together, in order to +reduce stalling. + +On z196, one surely want to use unrolling and pipelining, to perhaps +reach around 12 c/l. A major issue here and on z10 is ALCGR's 3 cycle +stalling. + + +mpn_mul_2, mpn_addmul_2 + +At least for older machines (z900, z990) with very slow MLGR, we +should use Karatsuba's algorithm on 2-limb units, making mul_2 and +addmul_2 the main multiplication primitives. The newer machines might +benefit less from this approach, perhaps in particular z10, where MLGR +clustering is more important. + +With Karatsuba, one could hope for around 16 cycles per accumulated +128 cross product, on z990. diff --git a/gmp/mpn/s390_64/addmul_1.asm b/gmp/mpn/s390_64/addmul_1.asm new file mode 100644 index 0000000000..84cca12361 --- /dev/null +++ b/gmp/mpn/s390_64/addmul_1.asm @@ -0,0 +1,72 @@ +dnl S/390-64 mpn_addmul_1 + +dnl Copyright 2011 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 cycles/limb +C z900 34 +C z990 23 +C z9 ? +C z10 28 +C z196 ? + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`v0', `%r5') + +define(`z', `%r9') + +ASM_START() +PROLOGUE(mpn_addmul_1) + stmg %r9, %r12, 72(%r15) + lghi %r12, 0 C zero index register + aghi %r12, 0 C clear carry flag + lghi %r11, 0 C clear carry limb + lghi z, 0 C keep register zero + +L(top): lg %r1, 0(%r12,up) + lg %r10, 0(%r12,rp) + mlgr %r0, v0 + alcgr %r1, %r10 + alcgr %r0, z + algr %r1, %r11 + lgr %r11, %r0 + stg %r1, 0(%r12,rp) + la %r12, 8(%r12) + brctg n, L(top) + + lghi %r2, 0 + alcgr %r2, %r11 + + lmg %r9, %r12, 72(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/aorrlsh1_n.asm b/gmp/mpn/s390_64/aorrlsh1_n.asm new file mode 100644 index 0000000000..697259efef --- /dev/null +++ b/gmp/mpn/s390_64/aorrlsh1_n.asm @@ -0,0 +1,168 @@ +dnl S/390-64 mpn_addlsh1_n and mpn_rsblsh1_n. + +dnl Copyright 2011 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 cycles/limb +C z900 9 +C z990 4.75 +C z9 ? +C z10 11 +C z196 ? + +C TODO +C * Optimise for small n, avoid 'la' like in aors_n.asm. +C * Tune to reach 3.5 c/l. For addlsh1, we could let the main alcgr propagate +C carry to the lsh1 alcgr. +C * Compute RETVAL for sublsh1_n less stupidly. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`vp', `%r4') +define(`n', `%r5') + +ifdef(`OPERATION_addlsh1_n',` + define(ADSB, alg) + define(ADSBC, alcg) + define(INITCY, `lghi %r9, -1') + define(RETVAL, `la %r2, 2(%r1,%r9)') + define(func, mpn_addlsh1_n) +') +ifdef(`OPERATION_rsblsh1_n',` + define(ADSB, slg) + define(ADSBC, slbg) + define(INITCY, `lghi %r9, 0') + define(RETVAL,`dnl + algr %r1, %r9 + lghi %r2, 1 + algr %r2, %r1') + define(func, mpn_rsblsh1_n) +') + +MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_rsblsh1_n) + +ASM_START() +PROLOGUE(func) + stmg %r6, %r9, 48(%r15) + + aghi n, 3 + lghi %r7, 3 + srlg %r0, n, 2 + ngr %r7, n C n mod 4 + je L(b1) + cghi %r7, 2 + jl L(b2) + jne L(b0) + +L(b3): lmg %r5, %r7, 0(vp) + la vp, 24(vp) + + algr %r5, %r5 + alcgr %r6, %r6 + alcgr %r7, %r7 + slbgr %r1, %r1 + + ADSB %r5, 0(up) + ADSBC %r6, 8(up) + ADSBC %r7, 16(up) + la up, 24(up) + slbgr %r9, %r9 + + stmg %r5, %r7, 0(rp) + la rp, 24(rp) + brctg %r0, L(top) + j L(end) + +L(b0): lghi %r1, -1 + INITCY + j L(top) + +L(b1): lg %r5, 0(vp) + la vp, 8(vp) + + algr %r5, %r5 + slbgr %r1, %r1 + ADSB %r5, 0(up) + la up, 8(up) + slbgr %r9, %r9 + + stg %r5, 0(rp) + la rp, 8(rp) + brctg %r0, L(top) + j L(end) + +L(b2): lmg %r5, %r6, 0(vp) + la vp, 16(vp) + + algr %r5, %r5 + alcgr %r6, %r6 + slbgr %r1, %r1 + + ADSB %r5, 0(up) + ADSBC %r6, 8(up) + la up, 16(up) + slbgr %r9, %r9 + + stmg %r5, %r6, 0(rp) + la rp, 16(rp) + brctg %r0, L(top) + j L(end) + +L(top): lmg %r5, %r8, 0(vp) + la vp, 32(vp) + + aghi %r1, 1 C restore carry + + alcgr %r5, %r5 + alcgr %r6, %r6 + alcgr %r7, %r7 + alcgr %r8, %r8 + + slbgr %r1, %r1 C save carry + + aghi %r9, 1 C restore carry + + ADSBC %r5, 0(up) + ADSBC %r6, 8(up) + ADSBC %r7, 16(up) + ADSBC %r8, 24(up) + la up, 32(up) + + slbgr %r9, %r9 C save carry + + stmg %r5, %r8, 0(rp) + la rp, 32(rp) + brctg %r0, L(top) + +L(end): RETVAL + lmg %r6, %r9, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/aors_n.asm b/gmp/mpn/s390_64/aors_n.asm new file mode 100644 index 0000000000..a3c3ca791c --- /dev/null +++ b/gmp/mpn/s390_64/aors_n.asm @@ -0,0 +1,136 @@ +dnl S/390-64 mpn_add_n and mpn_sub_n. + +dnl Copyright 2011 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 cycles/limb +C z900 5.5 +C z990 3 +C z9 ? +C z10 6 +C z196 ? + +C TODO +C * Optimise for small n +C * Use r0 and save/restore one less register +C * Using logops_n's v1 inner loop operand order make the loop about 20% +C faster, at the expense of highly alignment-dependent performance. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`vp', `%r4') +define(`n', `%r5') + +ifdef(`OPERATION_add_n', ` + define(ADSB, alg) + define(ADSBCR, alcgr) + define(ADSBC, alcg) + define(RETVAL,`dnl + lghi %r2, 0 + alcgr %r2, %r2') + define(func, mpn_add_n) + define(func_nc, mpn_add_nc)') +ifdef(`OPERATION_sub_n', ` + define(ADSB, slg) + define(ADSBCR, slbgr) + define(ADSBC, slbg) + define(RETVAL,`dnl + slbgr %r2, %r2 + lcgr %r2, %r2') + define(func, mpn_sub_n) + define(func_nc, mpn_sub_nc)') + +MULFUNC_PROLOGUE(mpn_add_n mpn_sub_n) + +ASM_START() +PROLOGUE(func) + stmg %r6, %r8, 48(%r15) + + aghi n, 3 + lghi %r7, 3 + srlg %r1, n, 2 + ngr %r7, n C n mod 4 + je L(b1) + cghi %r7, 2 + jl L(b2) + jne L(b0) + +L(b3): lmg %r5, %r7, 0(up) + la up, 24(up) + ADSB %r5, 0(vp) + ADSBC %r6, 8(vp) + ADSBC %r7, 16(vp) + la vp, 24(vp) + stmg %r5, %r7, 0(rp) + la rp, 24(rp) + brctg %r1, L(top) + j L(end) + +L(b0): lmg %r5, %r8, 0(up) C This redundant insns is no mistake, + la up, 32(up) C it is needed to make main loop run + ADSB %r5, 0(vp) C fast for n = 0 (mod 4). + ADSBC %r6, 8(vp) + j L(m0) + +L(b1): lg %r5, 0(up) + la up, 8(up) + ADSB %r5, 0(vp) + la vp, 8(vp) + stg %r5, 0(rp) + la rp, 8(rp) + brctg %r1, L(top) + j L(end) + +L(b2): lmg %r5, %r6, 0(up) + la up, 16(up) + ADSB %r5, 0(vp) + ADSBC %r6, 8(vp) + la vp, 16(vp) + stmg %r5, %r6, 0(rp) + la rp, 16(rp) + brctg %r1, L(top) + j L(end) + +L(top): lmg %r5, %r8, 0(up) + la up, 32(up) + ADSBC %r5, 0(vp) + ADSBC %r6, 8(vp) +L(m0): ADSBC %r7, 16(vp) + ADSBC %r8, 24(vp) + la vp, 32(vp) + stmg %r5, %r8, 0(rp) + la rp, 32(rp) + brctg %r1, L(top) + +L(end): RETVAL + lmg %r6, %r8, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/bdiv_dbm1c.asm b/gmp/mpn/s390_64/bdiv_dbm1c.asm new file mode 100644 index 0000000000..35e900a279 --- /dev/null +++ b/gmp/mpn/s390_64/bdiv_dbm1c.asm @@ -0,0 +1,65 @@ +dnl S/390-64 mpn_bdiv_dbm1c + +dnl Copyright 2011 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 cycles/limb +C z900 29 +C z990 22 +C z9 ? +C z10 19 +C z196 ? + +C INPUT PARAMETERS +define(`qp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`bd', `%r5') +define(`cy', `%r6') + +ASM_START() + TEXT + ALIGN(16) +PROLOGUE(mpn_bdiv_dbm1c) + stmg %r6, %r7, 48(%r15) + lghi %r7, 0 C zero index register + +L(top): lg %r1, 0(%r7,up) + mlgr %r0, bd + slgr %r6, %r1 + stg %r6, 0(%r7,qp) + la %r7, 8(%r7) + slbgr %r6, %r0 + brctg n, L(top) + + lgr %r2, %r6 + lmg %r6, %r7, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/copyd.asm b/gmp/mpn/s390_64/copyd.asm new file mode 100644 index 0000000000..8631e19f00 --- /dev/null +++ b/gmp/mpn/s390_64/copyd.asm @@ -0,0 +1,144 @@ +dnl S/390-64 mpn_copyd + +dnl Copyright 2011 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 cycles/limb +C z900 2.67 +C z990 1.5 +C z9 ? +C z10 1.8 +C z196 ? + +C FIXME: +C * Avoid saving/restoring callee-saves registers for n < 3. This could be +C done by setting rp=r1, up=r2, i=r0 and r3,r4,r5 for clock regs. +C We could then use r3...r10 in main loop. +C * Could we use some EX trick, modifying lmg/stmg, for the feed-in code? + +C INPUT PARAMETERS +define(`rp_param', `%r2') +define(`up_param', `%r3') +define(`n', `%r4') + +define(`rp', `%r8') +define(`up', `%r9') + +ASM_START() +PROLOGUE(mpn_copyd) + stmg %r6, %r11, 48(%r15) + + sllg %r1, n, 3 + la %r10, 8(n) + aghi %r1, -64 + srlg %r10, %r10, 3 + lghi %r11, -64 + + la rp, 0(%r1,rp_param) C FIXME use lay on z990 and later + la up, 0(%r1,up_param) C FIXME use lay on z990 and later + + lghi %r7, 7 + ngr %r7, n C n mod 8 + cghi %r7, 2 + jh L(b34567) + cghi %r7, 1 + je L(b1) + jh L(b2) + +L(b0): brctg %r10, L(top) + j L(end) + +L(b1): lg %r0, 56(up) + aghi up, -8 + stg %r0, 56(rp) + aghi rp, -8 + brctg %r10, L(top) + j L(end) + +L(b2): lmg %r0, %r1, 48(up) + aghi up, -16 + stmg %r0, %r1, 48(rp) + aghi rp, -16 + brctg %r10, L(top) + j L(end) + +L(b34567): + cghi %r7, 4 + jl L(b3) + je L(b4) + cghi %r7, 6 + je L(b6) + jh L(b7) + +L(b5): lmg %r0, %r4, 24(up) + aghi up, -40 + stmg %r0, %r4, 24(rp) + aghi rp, -40 + brctg %r10, L(top) + j L(end) + +L(b3): lmg %r0, %r2, 40(up) + aghi up, -24 + stmg %r0, %r2, 40(rp) + aghi rp, -24 + brctg %r10, L(top) + j L(end) + +L(b4): lmg %r0, %r3, 32(up) + aghi up, -32 + stmg %r0, %r3, 32(rp) + aghi rp, -32 + brctg %r10, L(top) + j L(end) + +L(b6): lmg %r0, %r5, 16(up) + aghi up, -48 + stmg %r0, %r5, 16(rp) + aghi rp, -48 + brctg %r10, L(top) + j L(end) + +L(b7): lmg %r0, %r6, 8(up) + aghi up, -56 + stmg %r0, %r6, 8(rp) + aghi rp, -56 + brctg %r10, L(top) + j L(end) + +L(top): lmg %r0, %r7, 0(up) + la up, 0(%r11,up) + stmg %r0, %r7, 0(rp) + la rp, 0(%r11,rp) + brctg %r10, L(top) + +L(end): lmg %r6, %r11, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/copyi.asm b/gmp/mpn/s390_64/copyi.asm new file mode 100644 index 0000000000..bfb88814ea --- /dev/null +++ b/gmp/mpn/s390_64/copyi.asm @@ -0,0 +1,68 @@ +dnl S/390-64 mpn_copyi + +dnl Copyright 2011 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 cycles/limb +C z900 1.25 +C z990 0.75 +C z9 ? +C z10 1 +C z196 ? + +C NOTE +C * This is based on GNU libc memcpy which was written by Martin Schwidefsky. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') + +ASM_START() +PROLOGUE(mpn_copyi) + ltgr %r4, %r4 + sllg %r4, %r4, 3 + je L(rtn) + aghi %r4, -1 + srlg %r5, %r4, 8 + ltgr %r5, %r5 C < 256 bytes to copy? + je L(1) + +L(top): mvc 0(256, rp), 0(up) + la rp, 256(rp) + la up, 256(up) + brctg %r5, L(top) + +L(1): bras %r5, L(2) C make r5 point to mvc insn + mvc 0(1, rp), 0(up) +L(2): ex %r4, 0(%r5) C execute mvc with length ((n-1) mod 256)+1 +L(rtn): br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/gmp-mparam.h b/gmp/mpn/s390_64/gmp-mparam.h new file mode 100644 index 0000000000..dacd9966a4 --- /dev/null +++ b/gmp/mpn/s390_64/gmp-mparam.h @@ -0,0 +1,175 @@ +/* S/390-64 gmp-mparam.h -- Compiler/machine parameter header file. + +Copyright 1991, 1993, 1994, 2000-2011 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. */ + +#define GMP_LIMB_BITS 64 +#define GMP_LIMB_BYTES 8 + +/* 1200 MHz z990 */ + +#define DIVREM_1_NORM_THRESHOLD 0 /* always */ +#define DIVREM_1_UNNORM_THRESHOLD 0 /* always */ +#define MOD_1_1P_METHOD 2 +#define MOD_1_NORM_THRESHOLD 0 /* always */ +#define MOD_1_UNNORM_THRESHOLD 0 /* always */ +#define MOD_1N_TO_MOD_1_1_THRESHOLD 9 +#define MOD_1U_TO_MOD_1_1_THRESHOLD 6 +#define MOD_1_1_TO_MOD_1_2_THRESHOLD 62 +#define MOD_1_2_TO_MOD_1_4_THRESHOLD 0 /* never mpn_mod_1s_2p */ +#define PREINV_MOD_1_TO_MOD_1_THRESHOLD 17 +#define USE_PREINV_DIVREM_1 1 +#define DIV_QR_1N_PI1_METHOD 1 +#define DIV_QR_1_NORM_THRESHOLD 1 +#define DIV_QR_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIV_QR_2_PI2_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIVEXACT_1_THRESHOLD 0 /* always */ +#define BMOD_1_TO_MOD_1_THRESHOLD 98 + +#define MUL_TOOM22_THRESHOLD 10 +#define MUL_TOOM33_THRESHOLD 41 +#define MUL_TOOM44_THRESHOLD 105 +#define MUL_TOOM6H_THRESHOLD 149 +#define MUL_TOOM8H_THRESHOLD 212 + +#define MUL_TOOM32_TO_TOOM43_THRESHOLD 65 +#define MUL_TOOM32_TO_TOOM53_THRESHOLD 69 +#define MUL_TOOM42_TO_TOOM53_THRESHOLD 72 +#define MUL_TOOM42_TO_TOOM63_THRESHOLD 64 +#define MUL_TOOM43_TO_TOOM54_THRESHOLD 55 + +#define SQR_BASECASE_THRESHOLD 0 /* always (native) */ +#define SQR_TOOM2_THRESHOLD 16 +#define SQR_TOOM3_THRESHOLD 57 +#define SQR_TOOM4_THRESHOLD 153 +#define SQR_TOOM6_THRESHOLD 204 +#define SQR_TOOM8_THRESHOLD 309 + +#define MULMID_TOOM42_THRESHOLD 20 + +#define MULMOD_BNM1_THRESHOLD 10 +#define SQRMOD_BNM1_THRESHOLD 11 + +#define MUL_FFT_MODF_THRESHOLD 220 /* k = 5 */ +#define MUL_FFT_TABLE3 \ + { { 220, 5}, { 11, 6}, { 6, 5}, { 13, 6}, \ + { 7, 5}, { 15, 6}, { 13, 7}, { 7, 6}, \ + { 15, 7}, { 8, 6}, { 17, 7}, { 9, 6}, \ + { 19, 7}, { 13, 8}, { 7, 7}, { 17, 8}, \ + { 9, 7}, { 19, 8}, { 13, 9}, { 7, 8}, \ + { 19, 9}, { 11, 8}, { 23,10}, { 7, 9}, \ + { 15, 8}, { 33, 9}, { 19, 8}, { 39, 9}, \ + { 23,10}, { 15, 9}, { 39,10}, { 23,11}, \ + { 15,10}, { 31, 9}, { 63,10}, { 39, 9}, \ + { 79,10}, { 47,11}, { 31,10}, { 63, 9}, \ + { 127, 8}, { 255,10}, { 71, 9}, { 143, 8}, \ + { 287,10}, { 79,11}, { 47,12}, { 31,11}, \ + { 63,10}, { 127, 9}, { 255, 8}, { 511,10}, \ + { 143, 9}, { 287,11}, { 79,10}, { 159, 9}, \ + { 319,10}, { 175, 9}, { 351, 8}, { 703, 7}, \ + { 1407,11}, { 95,10}, { 191, 9}, { 383,10}, \ + { 207,11}, { 111,10}, { 223,12}, { 63,11}, \ + { 127,10}, { 255, 9}, { 511,11}, { 143,10}, \ + { 287, 9}, { 575, 8}, { 1151,10}, { 319,11}, \ + { 175,10}, { 351, 9}, { 703,12}, { 95,11}, \ + { 191,10}, { 383, 9}, { 767,11}, { 207,10}, \ + { 415,11}, { 223,13}, { 8192,14}, { 16384,15}, \ + { 32768,16}, { 65536,17}, { 131072,18}, { 262144,19}, \ + { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \ + {8388608,24} } +#define MUL_FFT_TABLE3_SIZE 97 +#define MUL_FFT_THRESHOLD 1728 + +#define SQR_FFT_MODF_THRESHOLD 212 /* k = 5 */ +#define SQR_FFT_TABLE3 \ + { { 212, 5}, { 7, 4}, { 15, 5}, { 13, 6}, \ + { 7, 5}, { 15, 6}, { 15, 7}, { 8, 6}, \ + { 17, 7}, { 13, 8}, { 7, 7}, { 17, 8}, \ + { 9, 7}, { 19, 8}, { 11, 7}, { 23, 8}, \ + { 13, 9}, { 7, 8}, { 19, 9}, { 11, 8}, \ + { 25,10}, { 7, 9}, { 15, 8}, { 31, 9}, \ + { 19, 8}, { 39, 9}, { 23,10}, { 15, 9}, \ + { 39,10}, { 23,11}, { 15,10}, { 31, 9}, \ + { 63,10}, { 47,11}, { 31,10}, { 63, 9}, \ + { 127, 8}, { 255,10}, { 71, 9}, { 143, 8}, \ + { 287,10}, { 79,11}, { 47,12}, { 31,11}, \ + { 63,10}, { 127, 9}, { 255, 8}, { 511,10}, \ + { 143, 9}, { 287,11}, { 79,10}, { 159, 9}, \ + { 319, 8}, { 639,10}, { 175, 9}, { 351, 8}, \ + { 703,10}, { 191, 9}, { 383, 8}, { 767,10}, \ + { 207, 9}, { 415,11}, { 111,10}, { 223,12}, \ + { 63,11}, { 127,10}, { 255, 9}, { 511,11}, \ + { 143,10}, { 287, 9}, { 575, 8}, { 1151,11}, \ + { 159,10}, { 319,11}, { 175,10}, { 351, 9}, \ + { 703,11}, { 191,10}, { 383,11}, { 207,10}, \ + { 415,11}, { 223,13}, { 8192,14}, { 16384,15}, \ + { 32768,16}, { 65536,17}, { 131072,18}, { 262144,19}, \ + { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \ + {8388608,24} } +#define SQR_FFT_TABLE3_SIZE 93 +#define SQR_FFT_THRESHOLD 1600 + +#define MULLO_BASECASE_THRESHOLD 2 +#define MULLO_DC_THRESHOLD 33 +#define MULLO_MUL_N_THRESHOLD 3176 + +#define DC_DIV_QR_THRESHOLD 28 +#define DC_DIVAPPR_Q_THRESHOLD 107 +#define DC_BDIV_QR_THRESHOLD 31 +#define DC_BDIV_Q_THRESHOLD 78 + +#define INV_MULMOD_BNM1_THRESHOLD 43 +#define INV_NEWTON_THRESHOLD 129 +#define INV_APPR_THRESHOLD 117 + +#define BINV_NEWTON_THRESHOLD 149 +#define REDC_1_TO_REDC_N_THRESHOLD 38 + +#define MU_DIV_QR_THRESHOLD 748 +#define MU_DIVAPPR_Q_THRESHOLD 748 +#define MUPI_DIV_QR_THRESHOLD 65 +#define MU_BDIV_QR_THRESHOLD 562 +#define MU_BDIV_Q_THRESHOLD 734 + +#define POWM_SEC_TABLE 4,23,274,961,2783 + +#define MATRIX22_STRASSEN_THRESHOLD 11 +#define HGCD_THRESHOLD 79 +#define HGCD_APPR_THRESHOLD 70 +#define HGCD_REDUCE_THRESHOLD 1094 +#define GCD_DC_THRESHOLD 183 +#define GCDEXT_DC_THRESHOLD 148 +#define JACOBI_BASE_METHOD 4 + +#define GET_STR_DC_THRESHOLD 30 +#define GET_STR_PRECOMPUTE_THRESHOLD 41 +#define SET_STR_DC_THRESHOLD 402 +#define SET_STR_PRECOMPUTE_THRESHOLD 1104 + +#define FAC_DSC_THRESHOLD 842 +#define FAC_ODD_THRESHOLD 0 /* always */ diff --git a/gmp/mpn/s390_64/invert_limb.asm b/gmp/mpn/s390_64/invert_limb.asm new file mode 100644 index 0000000000..edcebddf1c --- /dev/null +++ b/gmp/mpn/s390_64/invert_limb.asm @@ -0,0 +1,94 @@ +dnl S/390-64 mpn_invert_limb + +dnl Contributed to the GNU project by Torbjorn Granlund. + +dnl Copyright 2011, 2013 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 cycles/limb +C z900 142 +C z990 86 +C z9 ? +C z10 120 +C z196 ? + +ASM_START() + TEXT + ALIGN(16) +PROLOGUE(mpn_invert_limb) + stg %r9, 72(%r15) + srlg %r9, %r2, 55 + agr %r9, %r9 + larl %r4, approx_tab-512 + srlg %r3, %r2, 24 + aghi %r3, 1 + lghi %r5, 1 + llgh %r4, 0(%r9, %r4) + sllg %r9, %r4, 11 + msgr %r4, %r4 + msgr %r4, %r3 + srlg %r4, %r4, 40 + aghi %r9, -1 + sgr %r9, %r4 + sllg %r0, %r9, 60 + sllg %r1, %r9, 13 + msgr %r9, %r9 + msgr %r9, %r3 + sgr %r0, %r9 + ngr %r5, %r2 + srlg %r4, %r2, 1 + srlg %r3, %r0, 47 + agr %r3, %r1 + agr %r4, %r5 + msgr %r4, %r3 + srlg %r1, %r3, 1 + lcgr %r5, %r5 + ngr %r1, %r5 + sgr %r1, %r4 + mlgr %r0, %r3 + srlg %r9, %r0, 1 + sllg %r4, %r3, 31 + agr %r4, %r9 + lgr %r1, %r4 + mlgr %r0, %r2 + algr %r1, %r2 + alcgr %r0, %r2 + lgr %r2, %r4 + sgr %r2, %r0 + lg %r9, 72(%r15) + br %r14 +EPILOGUE() + RODATA + ALIGN(2) +approx_tab: +forloop(i,256,512-1,dnl +` .word eval(0x7fd00/i) +')dnl +ASM_END() diff --git a/gmp/mpn/s390_64/logops_n.asm b/gmp/mpn/s390_64/logops_n.asm new file mode 100644 index 0000000000..914cfb6a41 --- /dev/null +++ b/gmp/mpn/s390_64/logops_n.asm @@ -0,0 +1,291 @@ +dnl S/390-64 logops. + +dnl Copyright 2011 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 cycles/limb variant 1 variant 2 variant 3 +C rp!=up rp=up +C z900 4.5 2.25 5.5 5.5 +C z990 2.75 2 3.25 3.25 +C z9 ? ? ? +C z10 3.25 3.75 3.75 +C z196 ? ? ? + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`vp', `%r4') +define(`n', `%r5') + +ifdef(`OPERATION_and_n',` + define(`func',`mpn_and_n') + define(`VARIANT_1') + define(`LOGOPC',`nc') + define(`LOGOP',`ng')') +ifdef(`OPERATION_andn_n',` + define(`func',`mpn_andn_n') + define(`VARIANT_2') + define(`LOGOP',`ng')') +ifdef(`OPERATION_nand_n',` + define(`func',`mpn_nand_n') + define(`VARIANT_3') + define(`LOGOP',`ng')') +ifdef(`OPERATION_ior_n',` + define(`func',`mpn_ior_n') + define(`VARIANT_1') + define(`LOGOPC',`oc') + define(`LOGOP',`og')') +ifdef(`OPERATION_iorn_n',` + define(`func',`mpn_iorn_n') + define(`VARIANT_2') + define(`LOGOP',`og')') +ifdef(`OPERATION_nior_n',` + define(`func',`mpn_nior_n') + define(`VARIANT_3') + define(`LOGOP',`og')') +ifdef(`OPERATION_xor_n',` + define(`func',`mpn_xor_n') + define(`VARIANT_1') + define(`LOGOPC',`xc') + define(`LOGOP',`xg')') +ifdef(`OPERATION_xnor_n',` + define(`func',`mpn_xnor_n') + define(`VARIANT_2') + define(`LOGOP',`xg')') + +MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n) + +ASM_START() +PROLOGUE(func) +ifdef(`VARIANT_1',` + cgr rp, up + jne L(normal) + + sllg n, n, 3 + aghi n, -1 + srlg %r1, n, 8 + ltgr %r1, %r1 C < 256 bytes to copy? + je L(1) + +L(tp): LOGOPC 0(256, rp), 0(vp) + la rp, 256(rp) + la vp, 256(vp) + brctg %r1, L(tp) + +L(1): bras %r1, L(2) C make r1 point to mvc insn + LOGOPC 0(1, rp), 0(vp) +L(2): ex n, 0(%r1) C execute mvc with length ((n-1) mod 256)+1 +L(rtn): br %r14 + + +L(normal): + stmg %r6, %r8, 48(%r15) + aghi n, 3 + lghi %r7, 3 + srlg %r0, n, 2 + ngr %r7, n C n mod 4 + je L(b1) + cghi %r7, 2 + jl L(b2) + jne L(top) + +L(b3): lmg %r5, %r7, 0(up) + la up, 24(up) + LOGOP %r5, 0(vp) + LOGOP %r6, 8(vp) + LOGOP %r7, 16(vp) + stmg %r5, %r7, 0(rp) + la rp, 24(rp) + la vp, 24(vp) + j L(mid) + +L(b1): lg %r5, 0(up) + la up, 8(up) + LOGOP %r5, 0(vp) + stg %r5, 0(rp) + la rp, 8(rp) + la vp, 8(vp) + j L(mid) + +L(b2): lmg %r5, %r6, 0(up) + la up, 16(up) + LOGOP %r5, 0(vp) + LOGOP %r6, 8(vp) + stmg %r5, %r6, 0(rp) + la rp, 16(rp) + la vp, 16(vp) + j L(mid) + +L(top): lmg %r5, %r8, 0(up) + la up, 32(up) + LOGOP %r5, 0(vp) + LOGOP %r6, 8(vp) + LOGOP %r7, 16(vp) + LOGOP %r8, 24(vp) + stmg %r5, %r8, 0(rp) + la rp, 32(rp) + la vp, 32(vp) +L(mid): brctg %r0, L(top) + + lmg %r6, %r8, 48(%r15) + br %r14 +') + +ifdef(`VARIANT_2',` + stmg %r6, %r8, 48(%r15) + lghi %r1, -1 + + aghi n, 3 + lghi %r7, 3 + srlg %r0, n, 2 + ngr %r7, n C n mod 4 + je L(b1) + cghi %r7, 2 + jl L(b2) + jne L(top) + +L(b3): lmg %r5, %r7, 0(vp) + la vp, 24(vp) + xgr %r5, %r1 + xgr %r6, %r1 + xgr %r7, %r1 + LOGOP %r5, 0(up) + LOGOP %r6, 8(up) + LOGOP %r7, 16(up) + stmg %r5, %r7, 0(rp) + la rp, 24(rp) + la up, 24(up) + j L(mid) + +L(b1): lg %r5, 0(vp) + la vp, 8(vp) + xgr %r5, %r1 + LOGOP %r5, 0(up) + stg %r5, 0(rp) + la rp, 8(rp) + la up, 8(up) + j L(mid) + +L(b2): lmg %r5, %r6, 0(vp) + la vp, 16(vp) + xgr %r5, %r1 + xgr %r6, %r1 + LOGOP %r5, 0(up) + LOGOP %r6, 8(up) + stmg %r5, %r6, 0(rp) + la rp, 16(rp) + la up, 16(up) + j L(mid) + +L(top): lmg %r5, %r8, 0(vp) + la vp, 32(vp) + xgr %r5, %r1 + xgr %r6, %r1 + xgr %r7, %r1 + xgr %r8, %r1 + LOGOP %r5, 0(up) + LOGOP %r6, 8(up) + LOGOP %r7, 16(up) + LOGOP %r8, 24(up) + la up, 32(up) + stmg %r5, %r8, 0(rp) + la rp, 32(rp) +L(mid): brctg %r0, L(top) + + lmg %r6, %r8, 48(%r15) + br %r14 +') + +ifdef(`VARIANT_3',` + stmg %r6, %r8, 48(%r15) + lghi %r1, -1 + + aghi n, 3 + lghi %r7, 3 + srlg %r0, n, 2 + ngr %r7, n C n mod 4 + je L(b1) + cghi %r7, 2 + jl L(b2) + jne L(top) + +L(b3): lmg %r5, %r7, 0(vp) + la vp, 24(vp) + LOGOP %r5, 0(up) + LOGOP %r6, 8(up) + xgr %r5, %r1 + xgr %r6, %r1 + LOGOP %r7, 16(up) + xgr %r7, %r1 + stmg %r5, %r7, 0(rp) + la rp, 24(rp) + la up, 24(up) + j L(mid) + +L(b1): lg %r5, 0(vp) + la vp, 8(vp) + LOGOP %r5, 0(up) + xgr %r5, %r1 + stg %r5, 0(rp) + la rp, 8(rp) + la up, 8(up) + j L(mid) + +L(b2): lmg %r5, %r6, 0(vp) + la vp, 16(vp) + LOGOP %r5, 0(up) + LOGOP %r6, 8(up) + xgr %r5, %r1 + xgr %r6, %r1 + stmg %r5, %r6, 0(rp) + la rp, 16(rp) + la up, 16(up) + j L(mid) + +L(top): lmg %r5, %r8, 0(vp) + la vp, 32(vp) + LOGOP %r5, 0(up) + LOGOP %r6, 8(up) + xgr %r5, %r1 + xgr %r6, %r1 + LOGOP %r7, 16(up) + LOGOP %r8, 24(up) + xgr %r7, %r1 + xgr %r8, %r1 + stmg %r5, %r8, 0(rp) + la up, 32(up) + la rp, 32(rp) +L(mid): brctg %r0, L(top) + + lmg %r6, %r8, 48(%r15) + br %r14 +') + +EPILOGUE() diff --git a/gmp/mpn/s390_64/lshift.asm b/gmp/mpn/s390_64/lshift.asm new file mode 100644 index 0000000000..4dae035a62 --- /dev/null +++ b/gmp/mpn/s390_64/lshift.asm @@ -0,0 +1,196 @@ +dnl S/390-64 mpn_lshift. + +dnl Copyright 2011, 2012, 2014 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 cycles/limb +C z900 7 +C z990 3 +C z9 ? +C z10 6 +C z196 ? + +C NOTES +C * This uses discrete loads and stores in a software pipeline. Using lmg and +C stmg is not faster. +C * One could assume more pipelining could approach 2.5 c/l, but we have not +C found any 8-way loop that runs better than the current 4-way loop. +C * Consider using the same feed-in code for 1 <= n <= 3 as for n mod 4, +C similarly to the x86_64 sqr_basecase feed-in. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`cnt', `%r5') + +define(`tnc', `%r6') + +ASM_START() +PROLOGUE(mpn_lshift) + cghi n, 3 + jh L(gt1) + + stmg %r6, %r7, 48(%r15) + larl %r1, L(tab)-4 + lcgr tnc, cnt + sllg n, n, 2 + b 0(n,%r1) +L(tab): j L(n1) + j L(n2) + j L(n3) + +L(n1): lg %r1, 0(up) + sllg %r0, %r1, 0(cnt) + stg %r0, 0(rp) + srlg %r2, %r1, 0(tnc) + lg %r6, 48(%r15) C restoring r7 not needed + br %r14 + +L(n2): lg %r1, 8(up) + srlg %r4, %r1, 0(tnc) + sllg %r0, %r1, 0(cnt) + j L(cj) + +L(n3): lg %r1, 16(up) + srlg %r4, %r1, 0(tnc) + sllg %r0, %r1, 0(cnt) + lg %r1, 8(up) + srlg %r7, %r1, 0(tnc) + ogr %r7, %r0 + sllg %r0, %r1, 0(cnt) + stg %r7, 16(rp) +L(cj): lg %r1, 0(up) + srlg %r7, %r1, 0(tnc) + ogr %r7, %r0 + sllg %r0, %r1, 0(cnt) + stg %r7, 8(rp) + stg %r0, 0(rp) + lgr %r2, %r4 + lmg %r6, %r7, 48(%r15) + br %r14 + +L(gt1): stmg %r6, %r13, 48(%r15) + lcgr tnc, cnt C tnc = -cnt + + sllg %r1, n, 3 + srlg %r0, n, 2 C loop count + + agr up, %r1 C point up at end of U + agr rp, %r1 C point rp at end of R + aghi up, -56 + aghi rp, -40 + + lghi %r7, 3 + ngr %r7, n + je L(b0) + cghi %r7, 2 + jl L(b1) + je L(b2) + +L(b3): lg %r7, 48(up) + srlg %r9, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + lg %r8, 40(up) + lg %r7, 32(up) + srlg %r4, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + ogr %r11, %r4 + la rp, 16(rp) + j L(lm3) + +L(b2): lg %r8, 48(up) + lg %r7, 40(up) + srlg %r9, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + la rp, 24(rp) + la up, 8(up) + j L(lm2) + +L(b1): lg %r7, 48(up) + srlg %r9, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + lg %r8, 40(up) + lg %r7, 32(up) + srlg %r4, %r8, 0(tnc) + sllg %r10, %r8, 0(cnt) + ogr %r11, %r4 + la rp, 32(rp) + la up, 16(up) + j L(lm1) + +L(b0): lg %r8, 48(up) + lg %r7, 40(up) + srlg %r9, %r8, 0(tnc) + sllg %r10, %r8, 0(cnt) + la rp, 40(rp) + la up, 24(up) + j L(lm0) + + ALIGN(8) +L(top): srlg %r4, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + ogr %r11, %r4 + stg %r10, 24(rp) +L(lm3): stg %r11, 16(rp) +L(lm2): srlg %r12, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + lg %r8, 24(up) + lg %r7, 16(up) + ogr %r13, %r12 + srlg %r4, %r8, 0(tnc) + sllg %r10, %r8, 0(cnt) + ogr %r11, %r4 + stg %r13, 8(rp) +L(lm1): stg %r11, 0(rp) +L(lm0): srlg %r12, %r7, 0(tnc) + aghi rp, -32 + sllg %r11, %r7, 0(cnt) + lg %r8, 8(up) + lg %r7, 0(up) + aghi up, -32 + ogr %r10, %r12 + brctg %r0, L(top) + +L(end): srlg %r4, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + ogr %r11, %r4 + stg %r10, 24(rp) + stg %r11, 16(rp) + srlg %r12, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + ogr %r13, %r12 + stg %r13, 8(rp) + stg %r11, 0(rp) + lgr %r2, %r9 + + lmg %r6, %r13, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/lshiftc.asm b/gmp/mpn/s390_64/lshiftc.asm new file mode 100644 index 0000000000..92552d529a --- /dev/null +++ b/gmp/mpn/s390_64/lshiftc.asm @@ -0,0 +1,207 @@ +dnl S/390-64 mpn_lshiftc. + +dnl Copyright 2011, 2014 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 cycles/limb +C z900 9 +C z990 3.5 +C z9 ? +C z10 7 +C z196 ? + +C NOTES +C * See notes in lshift.asm. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`cnt', `%r5') + +define(`tnc', `%r6') + +ASM_START() +PROLOGUE(mpn_lshiftc) + cghi n, 3 + jh L(gt1) + + stmg %r6, %r8, 48(%r15) + larl %r1, L(tab)-4 + lcgr tnc, cnt + sllg n, n, 2 + lghi %r8, -1 + b 0(n,%r1) +L(tab): j L(n1) + j L(n2) + j L(n3) + +L(n1): lg %r1, 0(up) + sllg %r0, %r1, 0(cnt) + xgr %r0, %r8 + stg %r0, 0(rp) + srlg %r2, %r1, 0(tnc) + lmg %r6, %r8, 48(%r15) + br %r14 + +L(n2): lg %r1, 8(up) + srlg %r4, %r1, 0(tnc) + sllg %r0, %r1, 0(cnt) + j L(cj) + +L(n3): lg %r1, 16(up) + srlg %r4, %r1, 0(tnc) + sllg %r0, %r1, 0(cnt) + lg %r1, 8(up) + srlg %r7, %r1, 0(tnc) + ogr %r7, %r0 + sllg %r0, %r1, 0(cnt) + xgr %r7, %r8 + stg %r7, 16(rp) +L(cj): lg %r1, 0(up) + srlg %r7, %r1, 0(tnc) + ogr %r7, %r0 + sllg %r0, %r1, 0(cnt) + xgr %r7, %r8 + xgr %r0, %r8 + stg %r7, 8(rp) + stg %r0, 0(rp) + lgr %r2, %r4 + lmg %r6, %r8, 48(%r15) + br %r14 + +L(gt1): stmg %r6, %r14, 48(%r15) + lcgr tnc, cnt C tnc = -cnt + + sllg %r1, n, 3 + srlg %r0, n, 2 C loop count + + agr up, %r1 C point up at end of U + agr rp, %r1 C point rp at end of R + aghi up, -56 + aghi rp, -40 + + lghi %r7, 3 + lghi %r14, -1 + ngr %r7, n + je L(b0) + cghi %r7, 2 + jl L(b1) + je L(b2) + +L(b3): lg %r7, 48(up) + srlg %r9, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + lg %r8, 40(up) + lg %r7, 32(up) + srlg %r4, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + ogr %r11, %r4 + la rp, 16(rp) + xgr %r11, %r14 + j L(lm3) + +L(b2): lg %r8, 48(up) + lg %r7, 40(up) + srlg %r9, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + la rp, 24(rp) + la up, 8(up) + j L(lm2) + +L(b1): lg %r7, 48(up) + srlg %r9, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + lg %r8, 40(up) + lg %r7, 32(up) + srlg %r4, %r8, 0(tnc) + sllg %r10, %r8, 0(cnt) + ogr %r11, %r4 + la rp, 32(rp) + la up, 16(up) + xgr %r11, %r14 + j L(lm1) + +L(b0): lg %r8, 48(up) + lg %r7, 40(up) + srlg %r9, %r8, 0(tnc) + sllg %r10, %r8, 0(cnt) + la rp, 40(rp) + la up, 24(up) + j L(lm0) + + ALIGN(8) +L(top): srlg %r4, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + ogr %r11, %r4 + xgr %r10, %r14 + xgr %r11, %r14 + stg %r10, 24(rp) +L(lm3): stg %r11, 16(rp) +L(lm2): srlg %r12, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + lg %r8, 24(up) + lg %r7, 16(up) + ogr %r13, %r12 + srlg %r4, %r8, 0(tnc) + sllg %r10, %r8, 0(cnt) + ogr %r11, %r4 + xgr %r13, %r14 + xgr %r11, %r14 + stg %r13, 8(rp) +L(lm1): stg %r11, 0(rp) +L(lm0): srlg %r12, %r7, 0(tnc) + aghi rp, -32 + sllg %r11, %r7, 0(cnt) + lg %r8, 8(up) + lg %r7, 0(up) + aghi up, -32 + ogr %r10, %r12 + brctg %r0, L(top) + +L(end): srlg %r4, %r8, 0(tnc) + sllg %r13, %r8, 0(cnt) + ogr %r11, %r4 + xgr %r10, %r14 + xgr %r11, %r14 + stg %r10, 24(rp) + stg %r11, 16(rp) + srlg %r12, %r7, 0(tnc) + sllg %r11, %r7, 0(cnt) + ogr %r13, %r12 + xgr %r13, %r14 + xgr %r11, %r14 + stg %r13, 8(rp) + stg %r11, 0(rp) + lgr %r2, %r9 + + lmg %r6, %r14, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/mod_34lsub1.asm b/gmp/mpn/s390_64/mod_34lsub1.asm new file mode 100644 index 0000000000..fd40011a8c --- /dev/null +++ b/gmp/mpn/s390_64/mod_34lsub1.asm @@ -0,0 +1,109 @@ +dnl S/390-64 mpn_mod_34lsub1 + +dnl Copyright 2011 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 cycles/limb +C z900 5.8 +C z990 2 +C z9 ? +C z10 4.5 +C z196 ? + +C TODO +C * Optimise summation code, see x86_64. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`n', `%r3') + +ASM_START() +PROLOGUE(mpn_mod_34lsub1) + stmg %r7, %r12, 56(%r15) + lghi %r11, 0 + lghi %r12, 0 + lghi %r0, 0 + lghi %r8, 0 + lghi %r9, 0 + lghi %r10, 0 + lghi %r7, 0 + aghi %r3, -3 + jl .L3 + +L(top): alg %r0, 0(%r2) + alcg %r12, 8(%r2) + alcg %r11, 16(%r2) + alcgr %r8, %r7 + la %r2, 24(%r2) + aghi %r3, -3 + jnl L(top) + + lgr %r7, %r8 + srlg %r1, %r11, 16 + nihh %r7, 0 C 0xffffffffffff + agr %r7, %r1 + srlg %r8, %r8, 48 + agr %r7, %r8 + sllg %r11, %r11, 32 + nihh %r11, 0 + agr %r7, %r11 +.L3: + cghi %r3, -3 + je .L6 + alg %r0, 0(%r2) + alcgr %r10, %r10 + cghi %r3, -2 + je .L6 + alg %r12, 8(%r2) + alcgr %r9, %r9 +.L6: + srlg %r1, %r0, 48 + nihh %r0, 0 C 0xffffffffffff + agr %r0, %r1 + agr %r0, %r7 + srlg %r1, %r12, 32 + agr %r0, %r1 + srlg %r1, %r10, 32 + agr %r0, %r1 + llgfr %r12, %r12 + srlg %r1, %r9, 16 + sllg %r12, %r12, 16 + llgfr %r10, %r10 + agr %r0, %r1 + llill %r2, 65535 + agr %r0, %r12 + sllg %r10, %r10, 16 + ngr %r2, %r9 + agr %r0, %r10 + sllg %r2, %r2, 32 + agr %r2, %r0 + lmg %r7, %r12, 56(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/mul_1.asm b/gmp/mpn/s390_64/mul_1.asm new file mode 100644 index 0000000000..a8f6da9a0f --- /dev/null +++ b/gmp/mpn/s390_64/mul_1.asm @@ -0,0 +1,66 @@ +dnl S/390-64 mpn_mul_1 + +dnl Copyright 2011 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 cycles/limb +C z900 29 +C z990 22 +C z9 ? +C z10 20 +C z196 ? + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`v0', `%r5') + +ASM_START() +PROLOGUE(mpn_mul_1) + stmg %r11, %r12, 88(%r15) + lghi %r12, 0 C zero index register + aghi %r12, 0 C clear carry flag + lghi %r11, 0 C clear carry limb + +L(top): lg %r1, 0(%r12,up) + mlgr %r0, v0 + alcgr %r1, %r11 + lgr %r11, %r0 C copy high part to carry limb + stg %r1, 0(%r12,rp) + la %r12, 8(%r12) + brctg n, L(top) + + lghi %r2, 0 + alcgr %r2, %r11 + + lmg %r11, %r12, 88(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/mul_basecase.asm b/gmp/mpn/s390_64/mul_basecase.asm new file mode 100644 index 0000000000..7d14ea98d2 --- /dev/null +++ b/gmp/mpn/s390_64/mul_basecase.asm @@ -0,0 +1,130 @@ +dnl S/390-64 mpn_mul_basecase. + +dnl Copyright 2011 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 cycles/limb +C z900 ? +C z990 23 +C z9 ? +C z10 28 +C z196 ? + +C TODO +C * Perhaps add special case for un <= 2. +C * Replace loops by faster code. The mul_1 and addmul_1 loops could be sped +C up by about 10%. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`un', `%r4') +define(`vp', `%r5') +define(`vn', `%r6') + +define(`zero', `%r8') + +ASM_START() +PROLOGUE(mpn_mul_basecase) + cghi un, 2 + jhe L(ge2) + +C un = vn = 1 + lg %r1, 0(vp) + mlg %r0, 0(up) + stg %r1, 0(rp) + stg %r0, 8(rp) + br %r14 + +L(ge2): C jne L(gen) + + +L(gen): +C mul_1 ======================================================================= + + stmg %r6, %r12, 48(%r15) + lghi zero, 0 + aghi un, -1 + + lg %r7, 0(vp) + lg %r11, 0(up) + lghi %r12, 8 C init index register + mlgr %r10, %r7 + lgr %r9, un + stg %r11, 0(rp) + cr %r15, %r15 C clear carry flag + +L(tm): lg %r1, 0(%r12,up) + mlgr %r0, %r7 + alcgr %r1, %r10 + lgr %r10, %r0 C copy high part to carry limb + stg %r1, 0(%r12,rp) + la %r12, 8(%r12) + brctg %r9, L(tm) + + alcgr %r0, zero + stg %r0, 0(%r12,rp) + +C addmul_1 loop =============================================================== + + aghi vn, -1 + je L(outer_end) +L(outer_loop): + + la rp, 8(rp) C rp += 1 + la vp, 8(vp) C up += 1 + lg %r7, 0(vp) + lg %r11, 0(up) + lghi %r12, 8 C init index register + mlgr %r10, %r7 + lgr %r9, un + alg %r11, 0(rp) + stg %r11, 0(rp) + +L(tam): lg %r1, 0(%r12,up) + lg %r11, 0(%r12,rp) + mlgr %r0, %r7 + alcgr %r1, %r11 + alcgr %r0, zero + algr %r1, %r10 + lgr %r10, %r0 + stg %r1, 0(%r12,rp) + la %r12, 8(%r12) + brctg %r9, L(tam) + + alcgr %r0, zero + stg %r0, 0(%r12,rp) + + brctg vn, L(outer_loop) +L(outer_end): + + lmg %r6, %r12, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/rshift.asm b/gmp/mpn/s390_64/rshift.asm new file mode 100644 index 0000000000..e870971650 --- /dev/null +++ b/gmp/mpn/s390_64/rshift.asm @@ -0,0 +1,195 @@ +dnl S/390-64 mpn_rshift. + +dnl Copyright 2011, 2014 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 cycles/limb +C z900 7 +C z990 3 +C z9 ? +C z10 6 +C z196 ? + +C NOTES +C * See notes in lshift.asm. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`cnt', `%r5') + +define(`tnc', `%r6') + +ASM_START() +PROLOGUE(mpn_rshift) + cghi n, 3 + jh L(gt1) + + stmg %r6, %r7, 48(%r15) + larl %r1, L(tab)-4 + lcgr tnc, cnt + sllg n, n, 2 + b 0(n,%r1) +L(tab): j L(n1) + j L(n2) + j L(n3) + +L(n1): lg %r1, 0(up) + srlg %r0, %r1, 0(cnt) + stg %r0, 0(rp) + sllg %r2, %r1, 0(tnc) + lg %r6, 48(%r15) C restoring r7 not needed + br %r14 + +L(n2): lg %r1, 0(up) + sllg %r4, %r1, 0(tnc) + srlg %r0, %r1, 0(cnt) + lg %r1, 8(up) + sllg %r7, %r1, 0(tnc) + ogr %r7, %r0 + srlg %r0, %r1, 0(cnt) + stg %r7, 0(rp) + stg %r0, 8(rp) + lgr %r2, %r4 + lmg %r6, %r7, 48(%r15) + br %r14 + + +L(n3): lg %r1, 0(up) + sllg %r4, %r1, 0(tnc) + srlg %r0, %r1, 0(cnt) + lg %r1, 8(up) + sllg %r7, %r1, 0(tnc) + ogr %r7, %r0 + srlg %r0, %r1, 0(cnt) + stg %r7, 0(rp) + lg %r1, 16(up) + sllg %r7, %r1, 0(tnc) + ogr %r7, %r0 + srlg %r0, %r1, 0(cnt) + stg %r7, 8(rp) + stg %r0, 16(rp) + lgr %r2, %r4 + lmg %r6, %r7, 48(%r15) + br %r14 + +L(gt1): stmg %r6, %r13, 48(%r15) + lcgr tnc, cnt C tnc = -cnt + + sllg %r1, n, 3 + srlg %r0, n, 2 C loop count + + lghi %r7, 3 + ngr %r7, n + je L(b0) + cghi %r7, 2 + jl L(b1) + je L(b2) + +L(b3): aghi rp, -8 + lg %r7, 0(up) + sllg %r9, %r7, 0(tnc) + srlg %r11, %r7, 0(cnt) + lg %r8, 8(up) + lg %r7, 16(up) + sllg %r4, %r8, 0(tnc) + srlg %r13, %r8, 0(cnt) + ogr %r11, %r4 + la up, 24(up) + j L(lm3) + +L(b2): aghi rp, -16 + lg %r8, 0(up) + lg %r7, 8(up) + sllg %r9, %r8, 0(tnc) + srlg %r13, %r8, 0(cnt) + la up, 16(up) + j L(lm2) + +L(b1): aghi rp, -24 + lg %r7, 0(up) + sllg %r9, %r7, 0(tnc) + srlg %r11, %r7, 0(cnt) + lg %r8, 8(up) + lg %r7, 16(up) + sllg %r4, %r8, 0(tnc) + srlg %r10, %r8, 0(cnt) + ogr %r11, %r4 + la up, 8(up) + j L(lm1) + +L(b0): aghi rp, -32 + lg %r8, 0(up) + lg %r7, 8(up) + sllg %r9, %r8, 0(tnc) + srlg %r10, %r8, 0(cnt) + j L(lm0) + + ALIGN(8) +L(top): sllg %r4, %r8, 0(tnc) + srlg %r13, %r8, 0(cnt) + ogr %r11, %r4 + stg %r10, 0(rp) +L(lm3): stg %r11, 8(rp) +L(lm2): sllg %r12, %r7, 0(tnc) + srlg %r11, %r7, 0(cnt) + lg %r8, 0(up) + lg %r7, 8(up) + ogr %r13, %r12 + sllg %r4, %r8, 0(tnc) + srlg %r10, %r8, 0(cnt) + ogr %r11, %r4 + stg %r13, 16(rp) +L(lm1): stg %r11, 24(rp) +L(lm0): sllg %r12, %r7, 0(tnc) + aghi rp, 32 + srlg %r11, %r7, 0(cnt) + lg %r8, 16(up) + lg %r7, 24(up) + aghi up, 32 + ogr %r10, %r12 + brctg %r0, L(top) + +L(end): sllg %r4, %r8, 0(tnc) + srlg %r13, %r8, 0(cnt) + ogr %r11, %r4 + stg %r10, 0(rp) + stg %r11, 8(rp) + sllg %r12, %r7, 0(tnc) + srlg %r11, %r7, 0(cnt) + ogr %r13, %r12 + stg %r13, 16(rp) + stg %r11, 24(rp) + lgr %r2, %r9 + + lmg %r6, %r13, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/sqr_basecase.asm b/gmp/mpn/s390_64/sqr_basecase.asm new file mode 100644 index 0000000000..bf31bd5546 --- /dev/null +++ b/gmp/mpn/s390_64/sqr_basecase.asm @@ -0,0 +1,203 @@ +dnl S/390-64 mpn_sqr_basecase. + +dnl Copyright 2011 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 cycles/limb +C z900 ? +C z990 23 +C z9 ? +C z10 28 +C z196 ? + +C TODO +C * Clean up. +C * Stop iterating addmul_1 loop at latest for n = 2, implement longer tail. +C This will ask for basecase handling of n = 3. +C * Update counters and pointers more straightforwardly, possibly lowering +C register usage. +C * Should we use this allocation-free style for more sqr_basecase asm +C implementations? The only disadvantage is that it requires R != U. +C * Replace loops by faster code. The mul_1 and addmul_1 loops could be sped +C up by about 10%. The sqr_diag_addlsh1 loop could probably be sped up even +C more. + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') + +define(`zero', `%r8') +define(`rp_saved', `%r9') +define(`up_saved', `%r13') +define(`n_saved', `%r14') + +ASM_START() +PROLOGUE(mpn_sqr_basecase) + aghi n, -2 + jhe L(ge2) + +C n = 1 + lg %r5, 0(up) + mlgr %r4, %r5 + stg %r5, 0(rp) + stg %r4, 8(rp) + br %r14 + +L(ge2): jne L(gen) + +C n = 2 + stmg %r6, %r8, 48(%r15) + lghi zero, 0 + + lg %r5, 0(up) + mlgr %r4, %r5 C u0 * u0 + lg %r1, 8(up) + mlgr %r0, %r1 C u1 * u1 + stg %r5, 0(rp) + + lg %r7, 0(up) + mlg %r6, 8(up) C u0 * u1 + algr %r7, %r7 + alcgr %r6, %r6 + alcgr %r0, zero + + algr %r4, %r7 + alcgr %r1, %r6 + alcgr %r0, zero + stg %r4, 8(rp) + stg %r1, 16(rp) + stg %r0, 24(rp) + + lmg %r6, %r8, 48(%r15) + br %r14 + +L(gen): +C mul_1 ======================================================================= + + stmg %r6, %r14, 48(%r15) + lghi zero, 0 + lgr up_saved, up + lgr rp_saved, rp + lgr n_saved, n + + lg %r6, 0(up) + lg %r11, 8(up) + lghi %r12, 16 C init index register + mlgr %r10, %r6 + lgr %r5, n + stg %r11, 8(rp) + cr %r15, %r15 C clear carry flag + +L(tm): lg %r1, 0(%r12,up) + mlgr %r0, %r6 + alcgr %r1, %r10 + lgr %r10, %r0 C copy high part to carry limb + stg %r1, 0(%r12,rp) + la %r12, 8(%r12) + brctg %r5, L(tm) + + alcgr %r0, zero + stg %r0, 0(%r12,rp) + +C addmul_1 loop =============================================================== + + aghi n, -1 + je L(outer_end) +L(outer_loop): + + la rp, 16(rp) C rp += 2 + la up, 8(up) C up += 1 + lg %r6, 0(up) + lg %r11, 8(up) + lghi %r12, 16 C init index register + mlgr %r10, %r6 + lgr %r5, n + alg %r11, 8(rp) + stg %r11, 8(rp) + +L(tam): lg %r1, 0(%r12,up) + lg %r7, 0(%r12,rp) + mlgr %r0, %r6 + alcgr %r1, %r7 + alcgr %r0, zero + algr %r1, %r10 + lgr %r10, %r0 + stg %r1, 0(%r12,rp) + la %r12, 8(%r12) + brctg %r5, L(tam) + + alcgr %r0, zero + stg %r0, 0(%r12,rp) + + brctg n, L(outer_loop) +L(outer_end): + + lg %r6, 8(up) + lg %r1, 16(up) + lgr %r7, %r0 C Same as: lg %r7, 24(,rp) + mlgr %r0, %r6 + algr %r1, %r7 + alcgr %r0, zero + stg %r1, 24(rp) + stg %r0, 32(rp) + +C sqr_diag_addlsh1 ============================================================ + +define(`up', `up_saved') +define(`rp', `rp_saved') + la n, 1(n_saved) + + lg %r1, 0(up) + mlgr %r0, %r1 + stg %r1, 0(rp) +C clr %r15, %r15 C clear carry (already clear per above) + +L(top): lg %r11, 8(up) + la up, 8(up) + lg %r6, 8(rp) + lg %r7, 16(rp) + mlgr %r10, %r11 + alcgr %r6, %r6 + alcgr %r7, %r7 + alcgr %r10, zero C propagate carry to high product limb + algr %r6, %r0 + alcgr %r7, %r11 + stmg %r6, %r7, 8(rp) + la rp, 16(rp) + lgr %r0, %r10 C copy carry limb + brctg n, L(top) + + alcgr %r0, zero + stg %r0, 8(rp) + + lmg %r6, %r14, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/sublsh1_n.asm b/gmp/mpn/s390_64/sublsh1_n.asm new file mode 100644 index 0000000000..50f127acef --- /dev/null +++ b/gmp/mpn/s390_64/sublsh1_n.asm @@ -0,0 +1,169 @@ +dnl S/390-64 mpn_sublsh1_n + +dnl Copyright 2011 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 cycles/limb +C z900 10 +C z990 5 +C z9 ? +C z10 12 +C z196 ? + +C TODO +C * Optimise for small n +C * Compute RETVAL for sublsh1_n less stupidly + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`vp', `%r4') +define(`n', `%r5') + +ifdef(`OPERATION_addlsh1_n',` + define(ADSBR, algr) + define(ADSBCR, alcgr) + define(INITCY, `lghi %r13, -1') + define(RETVAL, `la %r2, 2(%r1,%r13)') + define(func, mpn_addlsh1_n) +') +ifdef(`OPERATION_sublsh1_n',` + define(ADSBR, slgr) + define(ADSBCR, slbgr) + define(INITCY, `lghi %r13, 0') + define(RETVAL,`dnl + slgr %r1, %r13 + lghi %r2, 1 + algr %r2, %r1') + define(func, mpn_sublsh1_n) +') + +ASM_START() +PROLOGUE(mpn_sublsh1_n) + stmg %r6, %r13, 48(%r15) + + aghi n, 3 + lghi %r7, 3 + srlg %r0, n, 2 + ngr %r7, n C n mod 4 + je L(b1) + cghi %r7, 2 + jl L(b2) + jne L(b0) + +L(b3): lmg %r5, %r7, 0(up) + la up, 24(up) + lmg %r9, %r11, 0(vp) + la vp, 24(vp) + + algr %r9, %r9 + alcgr %r10, %r10 + alcgr %r11, %r11 + slbgr %r1, %r1 + + ADSBR %r5, %r9 + ADSBCR %r6, %r10 + ADSBCR %r7, %r11 + slbgr %r13, %r13 + + stmg %r5, %r7, 0(rp) + la rp, 24(rp) + brctg %r0, L(top) + j L(end) + +L(b0): lghi %r1, -1 + INITCY + j L(top) + +L(b1): lg %r5, 0(up) + la up, 8(up) + lg %r9, 0(vp) + la vp, 8(vp) + + algr %r9, %r9 + slbgr %r1, %r1 + ADSBR %r5, %r9 + slbgr %r13, %r13 + + stg %r5, 0(rp) + la rp, 8(rp) + brctg %r0, L(top) + j L(end) + +L(b2): lmg %r5, %r6, 0(up) + la up, 16(up) + lmg %r9, %r10, 0(vp) + la vp, 16(vp) + + algr %r9, %r9 + alcgr %r10, %r10 + slbgr %r1, %r1 + + ADSBR %r5, %r9 + ADSBCR %r6, %r10 + slbgr %r13, %r13 + + stmg %r5, %r6, 0(rp) + la rp, 16(rp) + brctg %r0, L(top) + j L(end) + +L(top): lmg %r9, %r12, 0(vp) + la vp, 32(vp) + + aghi %r1, 1 C restore carry + + alcgr %r9, %r9 + alcgr %r10, %r10 + alcgr %r11, %r11 + alcgr %r12, %r12 + + slbgr %r1, %r1 C save carry + + lmg %r5, %r8, 0(up) + la up, 32(up) + + aghi %r13, 1 C restore carry + + ADSBCR %r5, %r9 + ADSBCR %r6, %r10 + ADSBCR %r7, %r11 + ADSBCR %r8, %r12 + + slbgr %r13, %r13 C save carry + + stmg %r5, %r8, 0(rp) + la rp, 32(rp) + brctg %r0, L(top) + +L(end): RETVAL + lmg %r6, %r13, 48(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/submul_1.asm b/gmp/mpn/s390_64/submul_1.asm new file mode 100644 index 0000000000..91c4b06631 --- /dev/null +++ b/gmp/mpn/s390_64/submul_1.asm @@ -0,0 +1,70 @@ +dnl S/390-64 mpn_submul_1 + +dnl Copyright 2011 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 cycles/limb +C z900 35 +C z990 24 +C z9 ? +C z10 28 +C z196 ? + +C INPUT PARAMETERS +define(`rp', `%r2') +define(`up', `%r3') +define(`n', `%r4') +define(`v0', `%r5') + +ASM_START() +PROLOGUE(mpn_submul_1) + stmg %r9, %r12, 72(%r15) + lghi %r12, 0 + slgr %r11, %r11 + +L(top): lg %r1, 0(%r12, up) + lg %r10, 0(%r12, rp) + mlgr %r0, v0 + slbgr %r10, %r1 + slbgr %r9, %r9 + slgr %r0, %r9 C conditional incr + slgr %r10, %r11 + lgr %r11, %r0 + stg %r10, 0(%r12, rp) + la %r12, 8(%r12) + brctg %r4, L(top) + + lgr %r2, %r11 + slbgr %r9, %r9 + slgr %r2, %r9 + + lmg %r9, %r12, 72(%r15) + br %r14 +EPILOGUE() diff --git a/gmp/mpn/s390_64/z10/gmp-mparam.h b/gmp/mpn/s390_64/z10/gmp-mparam.h new file mode 100644 index 0000000000..c034f9b3b6 --- /dev/null +++ b/gmp/mpn/s390_64/z10/gmp-mparam.h @@ -0,0 +1,231 @@ +/* S/390-64 gmp-mparam.h -- Compiler/machine parameter header file. + +Copyright 1991, 1993, 1994, 2000-2011, 2014 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. */ + +#define GMP_LIMB_BITS 64 +#define GMP_LIMB_BYTES 8 + +/* 4400 MHz IBM z10 */ +/* FFT tuning limit = 15000000 */ +/* Generated by tuneup.c, 2014-03-12, gcc 4.7 */ + +#define DIVREM_1_NORM_THRESHOLD 0 /* always */ +#define DIVREM_1_UNNORM_THRESHOLD 4 +#define MOD_1_1P_METHOD 2 +#define MOD_1_NORM_THRESHOLD 0 /* always */ +#define MOD_1_UNNORM_THRESHOLD 0 /* always */ +#define MOD_1N_TO_MOD_1_1_THRESHOLD 7 +#define MOD_1U_TO_MOD_1_1_THRESHOLD 8 +#define MOD_1_1_TO_MOD_1_2_THRESHOLD 14 +#define MOD_1_2_TO_MOD_1_4_THRESHOLD 23 +#define PREINV_MOD_1_TO_MOD_1_THRESHOLD 29 +#define USE_PREINV_DIVREM_1 1 +#define DIV_QR_1N_PI1_METHOD 1 +#define DIV_QR_1_NORM_THRESHOLD 2 +#define DIV_QR_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIV_QR_2_PI2_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIVEXACT_1_THRESHOLD 0 /* always */ +#define BMOD_1_TO_MOD_1_THRESHOLD 56 + +#define MUL_TOOM22_THRESHOLD 8 +#define MUL_TOOM33_THRESHOLD 65 +#define MUL_TOOM44_THRESHOLD 88 +#define MUL_TOOM6H_THRESHOLD 125 +#define MUL_TOOM8H_THRESHOLD 163 + +#define MUL_TOOM32_TO_TOOM43_THRESHOLD 58 +#define MUL_TOOM32_TO_TOOM53_THRESHOLD 61 +#define MUL_TOOM42_TO_TOOM53_THRESHOLD 57 +#define MUL_TOOM42_TO_TOOM63_THRESHOLD 62 +#define MUL_TOOM43_TO_TOOM54_THRESHOLD 82 + +#define SQR_BASECASE_THRESHOLD 0 /* always (native) */ +#define SQR_TOOM2_THRESHOLD 12 +#define SQR_TOOM3_THRESHOLD 89 +#define SQR_TOOM4_THRESHOLD 130 +#define SQR_TOOM6_THRESHOLD 189 +#define SQR_TOOM8_THRESHOLD 260 + +#define MULMID_TOOM42_THRESHOLD 24 + +#define MULMOD_BNM1_THRESHOLD 9 +#define SQRMOD_BNM1_THRESHOLD 9 + +#define MUL_FFT_MODF_THRESHOLD 220 /* k = 5 */ +#define MUL_FFT_TABLE3 \ + { { 220, 5}, { 7, 4}, { 15, 5}, { 9, 6}, \ + { 5, 5}, { 11, 6}, { 6, 5}, { 13, 6}, \ + { 11, 7}, { 6, 6}, { 13, 7}, { 7, 6}, \ + { 15, 7}, { 13, 8}, { 7, 7}, { 16, 8}, \ + { 9, 7}, { 19, 8}, { 11, 7}, { 23, 8}, \ + { 13, 9}, { 7, 8}, { 15, 7}, { 31, 8}, \ + { 19, 9}, { 11, 8}, { 23,10}, { 7, 9}, \ + { 15, 8}, { 33, 9}, { 19, 8}, { 39, 9}, \ + { 27,10}, { 15, 9}, { 39,10}, { 23,11}, \ + { 15,10}, { 31, 9}, { 67,10}, { 39, 9}, \ + { 83,10}, { 47,11}, { 31,10}, { 63, 9}, \ + { 127, 8}, { 255, 7}, { 511,10}, { 71, 9}, \ + { 143, 8}, { 287, 7}, { 575,10}, { 79,11}, \ + { 47,12}, { 31,11}, { 63,10}, { 127, 9}, \ + { 255, 8}, { 511,10}, { 143, 9}, { 287, 8}, \ + { 575,11}, { 79,10}, { 159, 9}, { 319, 8}, \ + { 639,10}, { 175, 9}, { 351, 8}, { 703, 7}, \ + { 1407, 6}, { 2815,10}, { 191, 9}, { 383, 8}, \ + { 767, 9}, { 415,11}, { 111,10}, { 223, 9}, \ + { 447, 8}, { 895,12}, { 63,11}, { 127,10}, \ + { 255, 9}, { 511,11}, { 143,10}, { 287, 9}, \ + { 575, 8}, { 1151,10}, { 319, 9}, { 639,11}, \ + { 175, 9}, { 703, 8}, { 1407, 7}, { 2815,11}, \ + { 191,10}, { 415, 9}, { 831,11}, { 223,13}, \ + { 63,12}, { 127,11}, { 255,10}, { 511,11}, \ + { 287,10}, { 575, 9}, { 1151,12}, { 159,11}, \ + { 319,10}, { 639,11}, { 351,10}, { 703, 9}, \ + { 1407, 8}, { 2815,12}, { 191,11}, { 383,10}, \ + { 767,11}, { 415,10}, { 831,12}, { 223,10}, \ + { 895, 9}, { 1791,11}, { 479,13}, { 127,12}, \ + { 255,11}, { 511,10}, { 1023,12}, { 287,11}, \ + { 575,10}, { 1151,12}, { 319,11}, { 639,12}, \ + { 351,11}, { 703,10}, { 1407, 9}, { 2815,13}, \ + { 191,12}, { 383,11}, { 767,12}, { 415,11}, \ + { 831,10}, { 1663,12}, { 447,11}, { 895,10}, \ + { 1791, 9}, { 3583,12}, { 479,14}, { 127,13}, \ + { 255,12}, { 511,11}, { 1023,12}, { 575,11}, \ + { 1151,13}, { 319,12}, { 703,11}, { 1407,10}, \ + { 2815,13}, { 383,12}, { 767,11}, { 1535,12}, \ + { 831,11}, { 1663,13}, { 447,12}, { 895,11}, \ + { 1791,10}, { 3583,14}, { 255,13}, { 511,12}, \ + { 1023,13}, { 575,12}, { 1151,13}, { 639,12}, \ + { 1279,13}, { 703,12}, { 1407,11}, { 2815,14}, \ + { 383,13}, { 767,12}, { 1535,13}, { 831,12}, \ + { 1663,13}, { 895,12}, { 1791,11}, { 3583,15}, \ + { 255,14}, { 511,13}, { 1151,14}, { 639,13}, \ + { 1279,12}, { 2559,13}, { 1407,12}, { 2815,13}, \ + { 1471,14}, { 767,13}, { 1663,14}, { 895,13}, \ + { 1791,12}, { 3583,13}, { 8192,14}, { 16384,15}, \ + { 32768,16}, { 65536,17}, { 131072,18}, { 262144,19}, \ + { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \ + {8388608,24} } +#define MUL_FFT_TABLE3_SIZE 205 +#define MUL_FFT_THRESHOLD 1728 + +#define SQR_FFT_MODF_THRESHOLD 212 /* k = 5 */ +#define SQR_FFT_TABLE3 \ + { { 212, 5}, { 7, 4}, { 15, 5}, { 11, 6}, \ + { 6, 5}, { 13, 6}, { 7, 5}, { 15, 6}, \ + { 13, 7}, { 7, 6}, { 15, 7}, { 13, 8}, \ + { 7, 7}, { 16, 8}, { 9, 7}, { 19, 8}, \ + { 11, 7}, { 23, 8}, { 13, 9}, { 7, 8}, \ + { 19, 9}, { 11, 8}, { 23,10}, { 7, 9}, \ + { 15, 8}, { 31, 9}, { 19, 8}, { 39, 9}, \ + { 23,10}, { 15, 9}, { 39,10}, { 23,11}, \ + { 15,10}, { 31, 9}, { 63,10}, { 39, 9}, \ + { 79,10}, { 47,11}, { 31,10}, { 63, 9}, \ + { 127, 8}, { 255,10}, { 71, 9}, { 143, 8}, \ + { 287, 7}, { 575,10}, { 79,11}, { 47,12}, \ + { 31,11}, { 63,10}, { 127, 9}, { 255, 8}, \ + { 511,10}, { 143, 9}, { 287, 8}, { 575,11}, \ + { 79,10}, { 159, 9}, { 319, 8}, { 639,10}, \ + { 175, 9}, { 351, 8}, { 703,10}, { 191, 9}, \ + { 383, 8}, { 767,10}, { 207,11}, { 111,12}, \ + { 63,11}, { 127,10}, { 255, 9}, { 511,11}, \ + { 143,10}, { 287, 9}, { 575, 8}, { 1151,11}, \ + { 159,10}, { 319, 9}, { 639,11}, { 175,10}, \ + { 351, 9}, { 703,12}, { 95,11}, { 191,10}, \ + { 383, 9}, { 767,11}, { 207,10}, { 415,13}, \ + { 63,12}, { 127,11}, { 255,10}, { 511,11}, \ + { 287,10}, { 575, 9}, { 1151,12}, { 159,11}, \ + { 319,10}, { 639,11}, { 351,10}, { 703, 9}, \ + { 1407,12}, { 191,11}, { 383,10}, { 767,11}, \ + { 415,12}, { 223,11}, { 447,10}, { 895, 9}, \ + { 1791,13}, { 127,12}, { 255,11}, { 511,12}, \ + { 287,11}, { 575,10}, { 1151,12}, { 319,11}, \ + { 639,12}, { 351,11}, { 703,10}, { 1407,13}, \ + { 191,12}, { 383,11}, { 767,12}, { 415,11}, \ + { 831,10}, { 1663,12}, { 447,11}, { 895,10}, \ + { 1791, 9}, { 3583,12}, { 479,11}, { 959,10}, \ + { 1919,14}, { 127,13}, { 255,12}, { 511,11}, \ + { 1023,12}, { 575,11}, { 1151,13}, { 319,12}, \ + { 639,11}, { 1279,12}, { 703,11}, { 1407,10}, \ + { 2815,13}, { 383,12}, { 767,11}, { 1535,12}, \ + { 831,11}, { 1663,13}, { 447,12}, { 895,11}, \ + { 1791,12}, { 959,11}, { 1919,14}, { 255,13}, \ + { 511,12}, { 1023,13}, { 575,12}, { 1151,13}, \ + { 639,12}, { 1279,13}, { 703,12}, { 1407,11}, \ + { 2815,14}, { 383,13}, { 767,12}, { 1535,13}, \ + { 831,12}, { 1663,13}, { 895,12}, { 1791,11}, \ + { 3583,13}, { 959,12}, { 1919,15}, { 255,14}, \ + { 511,13}, { 1023,12}, { 2047,13}, { 1151,14}, \ + { 639,13}, { 1279,12}, { 2559,13}, { 1407,12}, \ + { 2815,14}, { 767,13}, { 1663,14}, { 895,13}, \ + { 1791,12}, { 3583,13}, { 8192,14}, { 16384,15}, \ + { 32768,16}, { 65536,17}, { 131072,18}, { 262144,19}, \ + { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \ + {8388608,24} } +#define SQR_FFT_TABLE3_SIZE 201 +#define SQR_FFT_THRESHOLD 1728 + +#define MULLO_BASECASE_THRESHOLD 0 /* always */ +#define MULLO_DC_THRESHOLD 34 +#define MULLO_MUL_N_THRESHOLD 3176 + +#define DC_DIV_QR_THRESHOLD 39 +#define DC_DIVAPPR_Q_THRESHOLD 151 +#define DC_BDIV_QR_THRESHOLD 44 +#define DC_BDIV_Q_THRESHOLD 107 + +#define INV_MULMOD_BNM1_THRESHOLD 14 +#define INV_NEWTON_THRESHOLD 163 +#define INV_APPR_THRESHOLD 154 + +#define BINV_NEWTON_THRESHOLD 171 +#define REDC_1_TO_REDC_N_THRESHOLD 46 + +#define MU_DIV_QR_THRESHOLD 792 +#define MU_DIVAPPR_Q_THRESHOLD 807 +#define MUPI_DIV_QR_THRESHOLD 81 +#define MU_BDIV_QR_THRESHOLD 654 +#define MU_BDIV_Q_THRESHOLD 792 + +#define POWM_SEC_TABLE 3,19,194,946,2424 + +#define MATRIX22_STRASSEN_THRESHOLD 17 +#define HGCD_THRESHOLD 117 +#define HGCD_APPR_THRESHOLD 145 +#define HGCD_REDUCE_THRESHOLD 1329 +#define GCD_DC_THRESHOLD 318 +#define GCDEXT_DC_THRESHOLD 265 +#define JACOBI_BASE_METHOD 4 + +#define GET_STR_DC_THRESHOLD 17 +#define GET_STR_PRECOMPUTE_THRESHOLD 35 +#define SET_STR_DC_THRESHOLD 1015 +#define SET_STR_PRECOMPUTE_THRESHOLD 2047 + +#define FAC_DSC_THRESHOLD 330 +#define FAC_ODD_THRESHOLD 23 |