1dnl  Alpha mpn_sqr_diagonal.
2
3dnl  Copyright 2001, 2002 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of the GNU Lesser General Public License as published
9dnl  by the Free Software Foundation; either version 3 of the License, or (at
10dnl  your option) any later version.
11
12dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15dnl  License for more details.
16
17dnl  You should have received a copy of the GNU Lesser General Public License
18dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20include(`../config.m4')
21
22C      cycles/limb
23C EV4:     42
24C EV5:     18
25C EV6:      3.45
26
27C  INPUT PARAMETERS
28C  rp	r16
29C  up	r17
30C  n	r18
31
32
33ASM_START()
34PROLOGUE(mpn_sqr_diagonal)
35	ldq	r2,0(r17)	C r2 = s1_limb
36	lda	r18,-2(r18)	C size -= 2
37	mulq	r2,r2,r3	C r3 = prod_low
38	umulh	r2,r2,r4	C r4 = prod_high
39	blt	r18,$Lend1	C jump if size was == 1
40	ldq	r2,8(r17)	C r2 = s1_limb
41	beq	r18,$Lend2	C jump if size was == 2
42
43	ALIGN(8)
44$Loop:	stq	r3,0(r16)
45	mulq	r2,r2,r3	C r3 = prod_low
46	lda	r18,-1(r18)	C size--
47	stq	r4,8(r16)
48	umulh	r2,r2,r4	C r4 = cy_limb
49	ldq	r2,16(r17)	C r2 = s1_limb
50	lda	r17,8(r17)	C s1_ptr++
51	lda	r16,16(r16)	C res_ptr++
52	bne	r18,$Loop
53
54$Lend2:	stq	r3,0(r16)
55	mulq	r2,r2,r3	C r3 = prod_low
56	stq	r4,8(r16)
57	umulh	r2,r2,r4	C r4 = cy_limb
58	stq	r3,16(r16)
59	stq	r4,24(r16)
60	ret	r31,(r26),1
61$Lend1:	stq	r3,0(r16)
62	stq	r4,8(r16)
63	ret	r31,(r26),1
64EPILOGUE(mpn_sqr_diagonal)
65ASM_END()
66