~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpn/powerpc32/mod_34lsub1.asm

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  PowerPC-32 mpn_mod_34lsub1 -- mpn remainder mod 2^24-1.
 
2
 
 
3
dnl  Copyright 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 2.1 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; see the file COPYING.LIB.  If not, write
 
19
dnl  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
20
dnl  Boston, MA 02110-1301, USA.
 
21
 
 
22
include(`../config.m4')
 
23
 
 
24
 
 
25
C                cycles/limb
 
26
C 603e:            ?
 
27
C 604e:            ?
 
28
C 75x (G3):        3.0
 
29
C 7400,7410 (G4):  3.0
 
30
C 744x,745x (G4+): 3.0
 
31
C power4/ppc970:   2.5
 
32
C power5:          2.5
 
33
 
 
34
C mp_limb_t mpn_mod_34lsub1 (mp_srcptr src, mp_size_t size)
 
35
C
 
36
C There seems no need to schedule the loads back, the code is still 3.0 c/l
 
37
C on 750/7400 no matter where they're placed.
 
38
C
 
39
C Alternatives:
 
40
C
 
41
C Fetching half words would allow add instead for accumulating, instead of
 
42
C adde and its serialization.  An outer loop would be required though, since
 
43
C 2^16 halfwords can overflow.  lhz+add would be 2.0 c/l, but if there's
 
44
C also a bdz or bdnz for each and a pointer update say every three limbs
 
45
C then the total would be 2.67 c/l which isn't much faster than the current
 
46
C simpler code.
 
47
 
 
48
ASM_START()
 
49
PROLOGUE(mpn_mod_34lsub1)
 
50
 
 
51
        C r3    src
 
52
        C r4    size
 
53
 
 
54
        mtctr   r4
 
55
        addic   r6, r3, 8               C &src[2], and clear CA
 
56
 
 
57
        lwz     r3, 0(r3)               C acc0 = src[0]
 
58
        bdz     L(done)
 
59
 
 
60
        lwz     r4, -4(r6)              C acc1 = src[1]
 
61
        bdz     L(two)
 
62
 
 
63
        lwz     r5, 0(r6)               C acc2 = src[2]
 
64
        lis     r7, 0                   C no carry if just three limbs
 
65
 
 
66
        bdz     L(three)
 
67
        lis     r7, 1                   C 0x10000 carry pos
 
68
 
 
69
L(top):
 
70
        C r3    acc0
 
71
        C r4    acc1
 
72
        C r5    acc2
 
73
        C r6    src, incrementing
 
74
        C r7    carry pos
 
75
 
 
76
        lwz     r0, 4(r6)
 
77
        adde    r3, r3, r0
 
78
        bdz     L(end0)
 
79
 
 
80
        lwz     r0, 8(r6)
 
81
        adde    r4, r4, r0
 
82
        bdz     L(end1)
 
83
 
 
84
        lwzu    r0, 12(r6)
 
85
        adde    r5, r5, r0
 
86
        bdnz    L(top)
 
87
 
 
88
 
 
89
        srwi    r7, r7, 8
 
90
L(end0):
 
91
        srwi    r7, r7, 8
 
92
L(end1):
 
93
        subfe   r0, r0, r0              C -1 if not CA
 
94
 
 
95
        andc    r7, r7, r0              C final carry, 0x10000, 0x100, 1 or 0
 
96
L(three):
 
97
        rlwinm  r6, r3, 0,8,31          C acc0 low
 
98
 
 
99
        add     r7, r7, r6
 
100
        rlwinm  r6, r3, 8,24,31         C acc0 high
 
101
 
 
102
        add     r7, r7, r6
 
103
        rlwinm  r6, r4, 8,8,23          C acc1 low
 
104
 
 
105
        add     r7, r7, r6
 
106
        rlwinm  r6, r4, 16,16,31        C acc1 high
 
107
 
 
108
        add     r7, r7, r6
 
109
        rlwinm  r6, r5, 16,8,15         C acc2 low
 
110
 
 
111
        add     r7, r7, r6
 
112
        rlwinm  r6, r5, 24,8,31         C acc2 high
 
113
 
 
114
        add     r3, r7, r6
 
115
 
 
116
L(done):
 
117
        blr
 
118
 
 
119
L(two):
 
120
        C r3    acc0
 
121
        C r4    acc1
 
122
 
 
123
        rlwinm  r5, r3, 8,24,31         C acc0 high
 
124
        rlwinm  r3, r3, 0,8,31          C acc0 low
 
125
 
 
126
        add     r3, r3, r5              C acc0 high + low
 
127
        rlwinm  r5, r4, 16,16,31        C acc1 high
 
128
 
 
129
        add     r3, r3, r5              C add acc1 high
 
130
        rlwinm  r5, r4, 8,8,23          C acc1 low
 
131
 
 
132
        add     r3, r3, r5              C add acc1 low
 
133
 
 
134
        blr
 
135
 
 
136
EPILOGUE()