github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/sparc64/ultrasparct3/dive_1.asm (about)

     1  dnl  SPARC T3/T4/T5 mpn_divexact_1.
     2  
     3  dnl  Contributed to the GNU project by Torbjörn Granlund.
     4  
     5  dnl  Copyright 2013 Free Software Foundation, Inc.
     6  
     7  dnl  This file is part of the GNU MP Library.
     8  dnl
     9  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
    10  dnl  it under the terms of either:
    11  dnl
    12  dnl    * the GNU Lesser General Public License as published by the Free
    13  dnl      Software Foundation; either version 3 of the License, or (at your
    14  dnl      option) any later version.
    15  dnl
    16  dnl  or
    17  dnl
    18  dnl    * the GNU General Public License as published by the Free Software
    19  dnl      Foundation; either version 2 of the License, or (at your option) any
    20  dnl      later version.
    21  dnl
    22  dnl  or both in parallel, as here.
    23  dnl
    24  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    25  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    26  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    27  dnl  for more details.
    28  dnl
    29  dnl  You should have received copies of the GNU General Public License and the
    30  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    31  dnl  see https://www.gnu.org/licenses/.
    32  
    33  include(`../config.m4')
    34  
    35  C                  cycles/limb
    36  C UltraSPARC T3:	31
    37  C UltraSPARC T4/T5:	20-26  hits 20 early, then sharply drops
    38  
    39  C INPUT PARAMETERS
    40  define(`qp',  `%i0')
    41  define(`ap',  `%i1')
    42  define(`n',   `%i2')
    43  define(`d',   `%i3')
    44  
    45  define(`dinv',`%o4')
    46  
    47  ASM_START()
    48  	REGISTER(%g2,#scratch)
    49  	REGISTER(%g3,#scratch)
    50  PROLOGUE(mpn_divexact_1)
    51  	save	%sp, -176, %sp
    52  	cmp	n, 1
    53  	bne,pt	%xcc, L(gt1)
    54  	 ldx	[ap], %o5
    55  	udivx	%o5, d, %g1
    56  	stx	%g1, [qp]
    57  	return	%i7+8
    58  	 nop
    59  
    60  L(gt1):	add	d, -1, %g1
    61  	andn	%g1, d, %g1
    62  	popc	%g1, %i4		C i4 = count_trailing_zeros(d)
    63  
    64  	srlx	d, %i4, d
    65  	srlx	d, 1, %g1
    66  	and	%g1, 127, %g1
    67  
    68  	LEA64(binvert_limb_table, g2, g4)
    69  	ldub	[%g2+%g1], %g1
    70  	add	%g1, %g1, %g2
    71  	mulx	%g1, %g1, %g1
    72  	mulx	%g1, d, %g1
    73  	sub	%g2, %g1, %g2
    74  	add	%g2, %g2, %g1
    75  	mulx	%g2, %g2, %g2
    76  	mulx	%g2, d, %g2
    77  	sub	%g1, %g2, %g1
    78  	add	%g1, %g1, %o7
    79  	mulx	%g1, %g1, %g1
    80  	mulx	%g1, d, %g1
    81  	add	n, -2, n
    82  	brz,pt	%i4, L(norm)
    83  	 sub	%o7, %g1, dinv
    84  
    85  L(unnorm):
    86  	mov	0, %g4
    87  	sub	%g0, %i4, %o2
    88  	srlx	%o5, %i4, %o5
    89  L(top_unnorm):
    90  	ldx	[ap+8], %g3
    91  	add	ap, 8, ap
    92  	sllx	%g3, %o2, %g5
    93  	or	%g5, %o5, %g5
    94  	srlx	%g3, %i4, %o5
    95  	subcc	%g5, %g4, %g4
    96  	mulx	%g4, dinv, %g1
    97  	stx	%g1, [qp]
    98  	add	qp, 8, qp
    99  	umulxhi(d, %g1, %g1)
   100  	addxc(	%g1, %g0, %g4)
   101  	brgz,pt	n, L(top_unnorm)
   102  	 add	n, -1, n
   103  
   104  	sub	%o5, %g4, %g4
   105  	mulx	%g4, dinv, %g1
   106  	stx	%g1, [qp]
   107  	return	%i7+8
   108  	 nop
   109  
   110  L(norm):
   111  	mulx	dinv, %o5, %g1
   112  	stx	%g1, [qp]
   113  	add	qp, 8, qp
   114  	addcc	%g0, 0, %g4
   115  L(top_norm):
   116  	umulxhi(d, %g1, %g1)
   117  	ldx	[ap+8], %g5
   118  	add	ap, 8, ap
   119  	addxc(	%g1, %g0, %g1)
   120  	subcc	%g5, %g1, %g1
   121  	mulx	%g1, dinv, %g1
   122  	stx	%g1, [qp]
   123  	add	qp, 8, qp
   124  	brgz,pt	n, L(top_norm)
   125  	 add	n, -1, n
   126  
   127  	return	%i7+8
   128  	 nop
   129  EPILOGUE()