github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/alpha/sqr_diag_addlsh1.asm (about)

     1  dnl  Alpha mpn_sqr_diag_addlsh1.
     2  
     3  dnl  Copyright 2013 Free Software Foundation, Inc.
     4  
     5  dnl  This file is part of the GNU MP Library.
     6  dnl
     7  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
     8  dnl  it under the terms of either:
     9  dnl
    10  dnl    * the GNU Lesser General Public License as published by the Free
    11  dnl      Software Foundation; either version 3 of the License, or (at your
    12  dnl      option) any later version.
    13  dnl
    14  dnl  or
    15  dnl
    16  dnl    * the GNU General Public License as published by the Free Software
    17  dnl      Foundation; either version 2 of the License, or (at your option) any
    18  dnl      later version.
    19  dnl
    20  dnl  or both in parallel, as here.
    21  dnl
    22  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    23  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    24  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    25  dnl  for more details.
    26  dnl
    27  dnl  You should have received copies of the GNU General Public License and the
    28  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    29  dnl  see https://www.gnu.org/licenses/.
    30  
    31  include(`../config.m4')
    32  
    33  C      cycles/limb
    34  C EV4:      ?
    35  C EV5:     10.2
    36  C EV6:      4.5
    37  
    38  C Ideally, one-way code could run at 9 c/l (limited by mulq+umulh) on ev5 and
    39  C about 3.75 c/l on ev6.  Two-way code could run at about 3.25 c/l on ev6.
    40  
    41  C Algorithm: We allow ourselves to propagate carry to a product high word
    42  C without worrying for carry out, since (B-1)^2 = B^2-2B+1 has a high word of
    43  C B-2, i.e, will not spill.  We propagate carry similarly to a product low word
    44  C since the problem value B-1 is a quadratic non-residue mod B, but our
    45  C products are squares.
    46  
    47  define(`rp',	`r16')
    48  define(`tp',	`r17')
    49  define(`up',	`r18')
    50  define(`n',	`r19')
    51  
    52  ASM_START()
    53  PROLOGUE(mpn_sqr_diag_addlsh1)
    54  	ldq	r0, 0(up)
    55  	bis	r31, r31, r21
    56  	bis	r31, r31, r3
    57  	mulq	r0, r0, r7
    58  	stq	r7, 0(rp)
    59  	umulh	r0, r0, r6
    60  	lda	n, -1(n)
    61  
    62  	ALIGN(16)
    63  L(top):	ldq	r0, 8(up)
    64  	lda	up, 8(up)
    65  	ldq	r8, 0(tp)
    66  	ldq	r20, 8(tp)
    67  	mulq	r0, r0, r7
    68  	lda	tp, 16(tp)
    69  	sll	r8, 1, r23
    70  	srl	r8, 63, r22
    71  	or	r21, r23, r23
    72  	sll	r20, 1, r24
    73  	addq	r3, r6, r6		C cannot carry per comment above
    74  	or	r22, r24, r24
    75  	addq	r23, r6, r21
    76  	umulh	r0, r0, r6
    77  	cmpult	r21, r23, r1
    78  	addq	r1, r7, r7		C cannot carry per comment above
    79  	stq	r21, 8(rp)
    80  	addq	r24, r7, r22
    81  	stq	r22, 16(rp)
    82  	lda	n, -1(n)
    83  	cmpult	r22, r7, r3
    84  	srl	r20, 63, r21
    85  	lda	rp, 16(rp)
    86  	bne	n, L(top)
    87  
    88  	addq	r3, r6, r6		C cannot carry per comment above
    89  	addq	r21, r6, r21
    90  	stq	r21, 8(rp)
    91  	ret	r31, (r26), 1
    92  EPILOGUE()
    93  ASM_END()