1dnl  PowerPC-32 mpn_sqr_diagonal.
2
3dnl  Copyright 2001, 2002, 2003, 2005 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 2.1 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; see the file COPYING.LIB.  If not, write
19dnl  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20dnl  Boston, MA 02110-1301, USA.
21
22include(`../config.m4')
23
24C                cycles/limb
25C 603e:             ?
26C 604e:             4.0
27C 75x (G3):        10.5
28C 7400,7410 (G4):  10.5
29C 744x,745x (G4+):  4.0
30C power4/ppc970:    8.6
31C power5:           7.0
32
33C INPUT PARAMETERS
34C rp	r3
35C up	r4
36C n	r5
37
38ASM_START()
39PROLOGUE(mpn_sqr_diagonal)
40	lwz	r6,0(r4)
41	mtctr	r5
42
43	addi	r3,r3,-4
44	bdz	L(end1)
45
46	lwzu	r7,4(r4)
47	mullw	r9,r6,r6
48	mulhwu	r11,r6,r6
49	bdz	L(end2)
50
51	lwzu	r6,4(r4)
52	mullw	r8,r7,r7
53	mulhwu	r10,r7,r7
54	bdz	L(ende)
55
56L(loop):
57	lwzu	r7,4(r4)
58	stw	r9,4(r3)
59	mullw	r9,r6,r6
60	stwu	r11,8(r3)
61	mulhwu	r11,r6,r6
62	bdz	L(endo)
63	lwzu	r6,4(r4)
64	stw	r8,4(r3)
65	mullw	r8,r7,r7
66	stwu	r10,8(r3)
67	mulhwu	r10,r7,r7
68	bdnz	L(loop)
69
70L(ende):
71	stw	r9,4(r3)
72	mullw	r9,r6,r6
73	stw	r11,8(r3)
74	mulhwu	r11,r6,r6
75	stw	r8,12(r3)
76	stw	r10,16(r3)
77	stw	r9,20(r3)
78	stw	r11,24(r3)
79	blr
80L(endo):
81	stw	r8,4(r3)
82	mullw	r8,r7,r7
83	stw	r10,8(r3)
84	mulhwu	r10,r7,r7
85	stw	r9,12(r3)
86	stw	r11,16(r3)
87	stw	r8,20(r3)
88	stw	r10,24(r3)
89	blr
90
91L(end2):
92	mullw	r8,r7,r7
93	stw	r9,4(r3)
94	mulhwu	r10,r7,r7
95	stw	r11,8(r3)
96	stw	r8,12(r3)
97	stw	r10,16(r3)
98	blr
99L(end1):
100	mullw	r9,r6,r6
101	mulhwu	r11,r6,r6
102	stw	r9,4(r3)
103	stw	r11,8(r3)
104	blr
105EPILOGUE(mpn_sqr_diagonal)
106