cb89bade2cc9e785f6e0a93293cedeb40afaeff0
[platform/upstream/gmp.git] / mpn / powerpc64 / com.asm
1 dnl  PowerPC-64 mpn_com.
2
3 dnl  Copyright 2003, 2004, 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 POWER3/PPC630          1?
24 C POWER4/PPC970          1.6
25 C POWER5                 ?
26 C POWER6                 ?
27 C POWER7                 1.45
28
29 C TODO
30 C  * 8-way unrolling brings timing down to about 1.3 cycles/limb.
31
32 C INPUT PARAMETERS
33 C rp    r3
34 C up    r4
35 C n     r5
36
37 ASM_START()
38 PROLOGUE(mpn_com)
39         rldic.  r0, r5, 3, 59   C r0 = (r5 & 3) << 3; cr0 = (n == 4t)?
40         cmpldi  cr6, r0, 16     C cr6 = (n cmp 4t + 2)?
41
42         addi    r5, r5, 3       C compute...
43 ifdef(`HAVE_ABI_mode32',
44 `       rldicl  r5, r5, 62,34', C ...branch count
45 `       rldicl  r5, r5, 62, 2') C ...branch count
46         mtctr   r5
47
48         add     r4, r4, r0      C offset up
49         add     r3, r3, r0      C offset rp
50
51         beq     cr0, L(L00)
52         blt     cr6, L(L01)
53         beq     cr6, L(L10)
54         b       L(L11)
55
56 L(L00): addi    r4, r4, 32
57         addi    r3, r3, 32
58
59         ALIGN(16)
60 L(oop): ld      r6, -32(r4)
61         nor     r6, r6, r6
62         std     r6, -32(r3)
63 L(L11): ld      r6, -24(r4)
64         nor     r6, r6, r6
65         std     r6, -24(r3)
66 L(L10): ld      r6, -16(r4)
67         nor     r6, r6, r6
68         std     r6, -16(r3)
69 L(L01): ld      r6, -8(r4)
70         nor     r6, r6, r6
71         addi    r4, r4, 32
72         std     r6, -8(r3)
73         addi    r3, r3, 32
74         bdnz    L(oop)
75
76         blr
77 EPILOGUE()