1dnl  Alpha mpn_sqr_diagonal.
2
3dnl  Copyright 2001, 2002, 2006 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:      ?
24C EV5:      ?
25C EV6:      2.3
26
27C  INPUT PARAMETERS
28C  rp	r16
29C  up	r17
30C  n	r18
31
32
33ASM_START()
34PROLOGUE(mpn_sqr_diagonal)
35	lda	r18, -2(r18)	C n -= 2
36	ldq	r0,   0(r17)
37	mulq	r0, r0, r4
38	umulh	r0, r0, r20
39	blt	r18, L(ex1)
40	ldq	r1,   8(r17)
41	mulq	r1, r1, r5
42	umulh	r1, r1, r21
43	beq	r18, L(ex2)
44	lda	r18, -2(r18)	C n -= 2
45	ldq	r0,  16(r17)
46	blt	r18, L(ex3)
47	ldq	r1,  24(r17)
48	beq	r18, L(ex4)
49
50	ALIGN(16)
51L(top):	lda	r18, -2(r18)	C n -= 2
52	stq	r4,   0(r16)
53	mulq	r0, r0, r4
54	stq	r20,  8(r16)
55	umulh	r0, r0, r20
56	ldq	r0,  32(r17)
57	blt	r18, L(x)
58	stq	r5,  16(r16)
59	mulq	r1, r1, r5
60	stq	r21, 24(r16)
61	umulh	r1, r1, r21
62	ldq	r1,  40(r17)
63	lda	r16, 32(r16)	C rp += 4
64	lda	r17, 16(r17)	C up += 2
65	bne	r18, L(top)
66
67	ALIGN(16)
68L(ex4):	stq	r4,   0(r16)
69	mulq	r0, r0, r4
70	stq	r20,  8(r16)
71	umulh	r0, r0, r20
72	stq	r5,  16(r16)
73	mulq	r1, r1, r5
74	stq	r21, 24(r16)
75	umulh	r1, r1, r21
76	stq	r4,  32(r16)
77	stq	r20, 40(r16)
78	stq	r5,  48(r16)
79	stq	r21, 56(r16)
80	ret	r31, (r26), 1
81	ALIGN(16)
82L(x):	stq	r5,  16(r16)
83	mulq	r1, r1, r5
84	stq	r21, 24(r16)
85	umulh	r1, r1, r21
86	stq	r4,  32(r16)
87	mulq	r0, r0, r4
88	stq	r20, 40(r16)
89	umulh	r0, r0, r20
90	stq	r5,  48(r16)
91	stq	r21, 56(r16)
92	stq	r4,  64(r16)
93	stq	r20, 72(r16)
94	ret	r31, (r26), 1
95L(ex1):	stq	r4,   0(r16)
96	stq	r20,  8(r16)
97	ret	r31, (r26), 1
98	ALIGN(16)
99L(ex2):	stq	r4,   0(r16)
100	stq	r20,  8(r16)
101	stq	r5,  16(r16)
102	stq	r21, 24(r16)
103	ret	r31, (r26), 1
104	ALIGN(16)
105L(ex3):	stq	r4,   0(r16)
106	mulq	r0, r0, r4
107	stq	r20,  8(r16)
108	umulh	r0, r0, r20
109	stq	r5,  16(r16)
110	stq	r21, 24(r16)
111	stq	r4,  32(r16)
112	stq	r20, 40(r16)
113	ret	r31, (r26), 1
114EPILOGUE()
115ASM_END()
116