1dnl SPARC64 mpn_gcd_11. 2 3dnl Based on the K7 gcd_1.asm, by Kevin Ryde. Rehacked for SPARC by Torbj��rn 4dnl Granlund. 5 6dnl Copyright 2000-2002, 2005, 2009, 2011-2013 Free Software Foundation, Inc. 7 8dnl This file is part of the GNU MP Library. 9dnl 10dnl The GNU MP Library is free software; you can redistribute it and/or modify 11dnl it under the terms of either: 12dnl 13dnl * the GNU Lesser General Public License as published by the Free 14dnl Software Foundation; either version 3 of the License, or (at your 15dnl option) any later version. 16dnl 17dnl or 18dnl 19dnl * the GNU General Public License as published by the Free Software 20dnl Foundation; either version 2 of the License, or (at your option) any 21dnl later version. 22dnl 23dnl or both in parallel, as here. 24dnl 25dnl The GNU MP Library is distributed in the hope that it will be useful, but 26dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 27dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28dnl for more details. 29dnl 30dnl You should have received copies of the GNU General Public License and the 31dnl GNU Lesser General Public License along with the GNU MP Library. If not, 32dnl see https://www.gnu.org/licenses/. 33 34include(`../config.m4') 35 36 37C cycles/bit (approx) 38C UltraSPARC 1&2: 5.1 39C UltraSPARC 3: 5.0 40C UltraSPARC T1: 11.4 41C UltraSPARC T3: 10 42C UltraSPARC T4: 6 43C Numbers measured with: speed -CD -s32-64 -t32 mpn_gcd_1 44 45C ctz_table[n] is the number of trailing zeros on n, or MAXSHIFT if n==0. 46 47deflit(MAXSHIFT, 7) 48deflit(MASK, eval((m4_lshift(1,MAXSHIFT))-1)) 49 50 RODATA 51 TYPE(ctz_table,object) 52ctz_table: 53 .byte MAXSHIFT 54forloop(i,1,MASK, 55` .byte m4_count_trailing_zeros(i) 56') 57 SIZE(ctz_table,.-ctz_table) 58 59define(`u0', `%o0') 60define(`v0', `%o1') 61 62ASM_START() 63 REGISTER(%g2,#scratch) 64 REGISTER(%g3,#scratch) 65PROLOGUE(mpn_gcd_11) 66 LEA64(ctz_table, o5, g4) 67 b L(odd) 68 mov u0, %o4 69 70 ALIGN(16) 71L(top): movcc %xcc, %o4, v0 C v = min(u,v) 72 movcc %xcc, %o2, %o0 C u = |v - u] 73L(mid): ldub [%o5+%g3], %g5 C 74 brz,a,pn %g3, L(shift_alot) C 75 srlx %o0, MAXSHIFT, %o0 76 srlx %o0, %g5, %o4 C new u, odd 77L(odd): subcc v0, %o4, %o2 C v - u, set flags for branch and movcc 78 sub %o4, v0, %o0 C u - v 79 bnz,pt %xcc, L(top) C 80 and %o2, MASK, %g3 C extract low MAXSHIFT bits from (v-u) 81 82 retl 83 mov v0, %o0 84 85L(shift_alot): 86 b L(mid) 87 and %o0, MASK, %g3 C 88EPILOGUE() 89