Upload Tizen:Base source
[external/gmp.git] / mpn / powerpc64 / logops_n.asm
1 dnl  PowerPC-64 mpn_and_n, mpn_andn_n, mpn_nand_n, mpn_ior_n, mpn_iorn_n,
2 dnl  mpn_nior_n, mpn_xor_n, mpn_xnor_n -- mpn bitwise logical operations.
3
4 dnl  Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C               cycles/limb
24 C POWER3/PPC630:     1.75
25 C POWER4/PPC970:     2.10
26
27 C   n      POWER3/PPC630   POWER4/PPC970
28 C     1        15.00           15.33
29 C     2         7.50            7.99
30 C     3         5.33            6.00
31 C     4         4.50            4.74
32 C     5         4.20            4.39
33 C     6         3.50            3.99
34 C     7         3.14            3.64
35 C     8         3.00            3.36
36 C     9         3.00            3.36
37 C    10         2.70            3.25
38 C    11         2.63            3.11
39 C    12         2.58            3.00
40 C    13         2.61            3.02
41 C    14         2.42            2.82
42 C    15         2.40            2.79
43 C    50         2.08            2.67
44 C   100         1.85            2.31
45 C   200         1.80            2.18
46 C   400         1.77            2.14
47 C  1000         1.76            2.10#
48 C  2000         1.75#           2.13
49 C  4000         2.30            2.57
50 C  8000         2.62            2.58
51 C 16000         2.52            4.25
52 C 32000         2.49           16.25
53 C 64000         2.66           18.76
54
55 ifdef(`OPERATION_and_n',
56 `       define(`func',`mpn_and_n')
57         define(`logop',         `and')')
58 ifdef(`OPERATION_andn_n',
59 `       define(`func',`mpn_andn_n')
60         define(`logop',         `andc')')
61 ifdef(`OPERATION_nand_n',
62 `       define(`func',`mpn_nand_n')
63         define(`logop',         `nand')')
64 ifdef(`OPERATION_ior_n',
65 `       define(`func',`mpn_ior_n')
66         define(`logop',         `or')')
67 ifdef(`OPERATION_iorn_n',
68 `       define(`func',`mpn_iorn_n')
69         define(`logop',         `orc')')
70 ifdef(`OPERATION_nior_n',
71 `       define(`func',`mpn_nior_n')
72         define(`logop',         `nor')')
73 ifdef(`OPERATION_xor_n',
74 `       define(`func',`mpn_xor_n')
75         define(`logop',         `xor')')
76 ifdef(`OPERATION_xnor_n',
77 `       define(`func',`mpn_xnor_n')
78         define(`logop',         `eqv')')
79
80 C INPUT PARAMETERS
81 C rp    r3
82 C up    r4
83 C vp    r5
84 C n     r6
85
86 MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n)
87
88 ASM_START()
89 PROLOGUE(func)
90         ld      r8, 0(r4)       C read lowest u limb
91         ld      r9, 0(r5)       C read lowest v limb
92         addi    r6, r6, 3       C compute branch count (1)
93         rldic.  r0, r6, 3, 59   C r0 = (n-1 & 3) << 3; cr0 = (n == 4(t+1))?
94         cmpldi  cr6, r0, 16     C cr6 = (n cmp 4t + 3)
95
96 ifdef(`HAVE_ABI_mode32',
97 `       rldicl  r6, r6, 62,34', C ...branch count
98 `       rldicl  r6, r6, 62, 2') C ...branch count
99         mtctr   r6
100
101         ld      r6, 0(r4)       C read lowest u limb (again)
102         ld      r7, 0(r5)       C read lowest v limb (again)
103
104         add     r5, r5, r0      C offset vp
105         add     r4, r4, r0      C offset up
106         add     r3, r3, r0      C offset rp
107
108         beq     cr0, L(L01)
109         blt     cr6, L(L10)
110         beq     cr6, L(L11)
111         b       L(L00)
112
113 L(oop): ld      r8, -24(r4)
114         ld      r9, -24(r5)
115         logop   r10, r6, r7
116         std     r10, -32(r3)
117 L(L00): ld      r6, -16(r4)
118         ld      r7, -16(r5)
119         logop   r10, r8, r9
120         std     r10, -24(r3)
121 L(L11): ld      r8, -8(r4)
122         ld      r9, -8(r5)
123         logop   r10, r6, r7
124         std     r10, -16(r3)
125 L(L10): ld      r6, 0(r4)
126         ld      r7, 0(r5)
127         logop   r10, r8, r9
128         std     r10, -8(r3)
129 L(L01): addi    r5, r5, 32
130         addi    r4, r4, 32
131         addi    r3, r3, 32
132         bdnz    L(oop)
133
134         logop   r10, r6, r7
135         std     r10, -32(r3)
136         blr
137 EPILOGUE()