Tizen 2.1 base
[external/gmp.git] / mpn / powerpc32 / sqr_diagonal.asm
1 dnl  PowerPC-32 mpn_sqr_diagonal.
2
3 dnl  Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 C                cycles/limb
23 C 603e:             ?
24 C 604e:             4.0
25 C 75x (G3):        10.5
26 C 7400,7410 (G4):  10.5
27 C 744x,745x (G4+):  4.0
28 C power4/ppc970:    8.6
29 C power5:           7.0
30
31 C INPUT PARAMETERS
32 C rp    r3
33 C up    r4
34 C n     r5
35
36 ASM_START()
37 PROLOGUE(mpn_sqr_diagonal)
38         lwz     r6,0(r4)
39         mtctr   r5
40
41         addi    r3,r3,-4
42         bdz     L(end1)
43
44         lwzu    r7,4(r4)
45         mullw   r9,r6,r6
46         mulhwu  r11,r6,r6
47         bdz     L(end2)
48
49         lwzu    r6,4(r4)
50         mullw   r8,r7,r7
51         mulhwu  r10,r7,r7
52         bdz     L(ende)
53
54 L(loop):
55         lwzu    r7,4(r4)
56         stw     r9,4(r3)
57         mullw   r9,r6,r6
58         stwu    r11,8(r3)
59         mulhwu  r11,r6,r6
60         bdz     L(endo)
61         lwzu    r6,4(r4)
62         stw     r8,4(r3)
63         mullw   r8,r7,r7
64         stwu    r10,8(r3)
65         mulhwu  r10,r7,r7
66         bdnz    L(loop)
67
68 L(ende):
69         stw     r9,4(r3)
70         mullw   r9,r6,r6
71         stw     r11,8(r3)
72         mulhwu  r11,r6,r6
73         stw     r8,12(r3)
74         stw     r10,16(r3)
75         stw     r9,20(r3)
76         stw     r11,24(r3)
77         blr
78 L(endo):
79         stw     r8,4(r3)
80         mullw   r8,r7,r7
81         stw     r10,8(r3)
82         mulhwu  r10,r7,r7
83         stw     r9,12(r3)
84         stw     r11,16(r3)
85         stw     r8,20(r3)
86         stw     r10,24(r3)
87         blr
88
89 L(end2):
90         mullw   r8,r7,r7
91         stw     r9,4(r3)
92         mulhwu  r10,r7,r7
93         stw     r11,8(r3)
94         stw     r8,12(r3)
95         stw     r10,16(r3)
96         blr
97 L(end1):
98         mullw   r9,r6,r6
99         mulhwu  r11,r6,r6
100         stw     r9,4(r3)
101         stw     r11,8(r3)
102         blr
103 EPILOGUE(mpn_sqr_diagonal)