Blame mpn/alpha/sqr_diag_addlsh1.asm

Packit 5c3484
dnl  Alpha mpn_sqr_diag_addlsh1.
Packit 5c3484
Packit 5c3484
dnl  Copyright 2013 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
dnl  This file is part of the GNU MP Library.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
dnl  it under the terms of either:
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU Lesser General Public License as published by the Free
Packit 5c3484
dnl      Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
dnl      option) any later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU General Public License as published by the Free Software
Packit 5c3484
dnl      Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
dnl      later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or both in parallel, as here.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
dnl  for more details.
Packit 5c3484
dnl
Packit 5c3484
dnl  You should have received copies of the GNU General Public License and the
Packit 5c3484
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
dnl  see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
include(`../config.m4')
Packit 5c3484
Packit 5c3484
C      cycles/limb
Packit 5c3484
C EV4:      ?
Packit 5c3484
C EV5:     10.2
Packit 5c3484
C EV6:      4.5
Packit 5c3484
Packit 5c3484
C Ideally, one-way code could run at 9 c/l (limited by mulq+umulh) on ev5 and
Packit 5c3484
C about 3.75 c/l on ev6.  Two-way code could run at about 3.25 c/l on ev6.
Packit 5c3484
Packit 5c3484
C Algorithm: We allow ourselves to propagate carry to a product high word
Packit 5c3484
C without worrying for carry out, since (B-1)^2 = B^2-2B+1 has a high word of
Packit 5c3484
C B-2, i.e, will not spill.  We propagate carry similarly to a product low word
Packit 5c3484
C since the problem value B-1 is a quadratic non-residue mod B, but our
Packit 5c3484
C products are squares.
Packit 5c3484
Packit 5c3484
define(`rp',	`r16')
Packit 5c3484
define(`tp',	`r17')
Packit 5c3484
define(`up',	`r18')
Packit 5c3484
define(`n',	`r19')
Packit 5c3484
Packit 5c3484
ASM_START()
Packit 5c3484
PROLOGUE(mpn_sqr_diag_addlsh1)
Packit 5c3484
	ldq	r0, 0(up)
Packit 5c3484
	bis	r31, r31, r21
Packit 5c3484
	bis	r31, r31, r3
Packit 5c3484
	mulq	r0, r0, r7
Packit 5c3484
	stq	r7, 0(rp)
Packit 5c3484
	umulh	r0, r0, r6
Packit 5c3484
	lda	n, -1(n)
Packit 5c3484
Packit 5c3484
	ALIGN(16)
Packit 5c3484
L(top):	ldq	r0, 8(up)
Packit 5c3484
	lda	up, 8(up)
Packit 5c3484
	ldq	r8, 0(tp)
Packit 5c3484
	ldq	r20, 8(tp)
Packit 5c3484
	mulq	r0, r0, r7
Packit 5c3484
	lda	tp, 16(tp)
Packit 5c3484
	sll	r8, 1, r23
Packit 5c3484
	srl	r8, 63, r22
Packit 5c3484
	or	r21, r23, r23
Packit 5c3484
	sll	r20, 1, r24
Packit 5c3484
	addq	r3, r6, r6		C cannot carry per comment above
Packit 5c3484
	or	r22, r24, r24
Packit 5c3484
	addq	r23, r6, r21
Packit 5c3484
	umulh	r0, r0, r6
Packit 5c3484
	cmpult	r21, r23, r1
Packit 5c3484
	addq	r1, r7, r7		C cannot carry per comment above
Packit 5c3484
	stq	r21, 8(rp)
Packit 5c3484
	addq	r24, r7, r22
Packit 5c3484
	stq	r22, 16(rp)
Packit 5c3484
	lda	n, -1(n)
Packit 5c3484
	cmpult	r22, r7, r3
Packit 5c3484
	srl	r20, 63, r21
Packit 5c3484
	lda	rp, 16(rp)
Packit 5c3484
	bne	n, L(top)
Packit 5c3484
Packit 5c3484
	addq	r3, r6, r6		C cannot carry per comment above
Packit 5c3484
	addq	r21, r6, r21
Packit 5c3484
	stq	r21, 8(rp)
Packit 5c3484
	ret	r31, (r26), 1
Packit 5c3484
EPILOGUE()
Packit 5c3484
ASM_END()