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

« back to all changes in this revision

Viewing changes to src/gmp/mpn/powerpc32/diveby3.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_divexact_by3 -- mpn by 3 exact division
 
2
 
 
3
dnl  Copyright 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
 
4
dnl
 
5
dnl  This file is part of the GNU MP Library.
 
6
dnl
 
7
dnl  The GNU MP Library is free software; you can redistribute it and/or
 
8
dnl  modify it under the terms of the GNU Lesser General Public License as
 
9
dnl  published by the Free Software Foundation; either version 2.1 of the
 
10
dnl  License, or (at your option) any later version.
 
11
dnl
 
12
dnl  The GNU MP Library is distributed in the hope that it will be useful,
 
13
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
dnl  Lesser General Public License for more details.
 
16
dnl
 
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  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
20
dnl  Boston, MA 02110-1301, USA.
 
21
 
 
22
include(`../config.m4')
 
23
 
 
24
C                cycles/limb
 
25
C 603e:              ?
 
26
C 604e:              ?
 
27
C 75x (G3):          ?
 
28
C 7400,7410 (G4):    8
 
29
C 744x,745x (G4+):   6
 
30
C power4/ppc970:    12
 
31
C power5:            ?
 
32
 
 
33
C void mpn_divexact_by3 (mp_ptr dst, mp_srcptr src, mp_size_t size);
 
34
C
 
35
C We avoid the slow subfe instruction and instead rely on an extremely unlikely
 
36
C branch.
 
37
C
 
38
C The mullw has the inverse in the first operand, since 0xAA..AB won't allow
 
39
C any early-out.  The src[] data normally won't either, but there's at least
 
40
C a chance, whereas 0xAA..AB never will.  If, for instance, src[] is all
 
41
C zeros (not a sensible input of course) we run at 7.0 c/l on ppc750.
 
42
C
 
43
C The mulhwu has the "3" multiplier in the second operand, which lets 750 and
 
44
C 7400 use an early-out.
 
45
 
 
46
C INPUT PARAMETERS
 
47
define(`rp', `r3')
 
48
define(`up', `r4')
 
49
define(`n',  `r5')
 
50
define(`cy', `r6')
 
51
 
 
52
ASM_START()
 
53
PROLOGUE(mpn_divexact_by3c)
 
54
        lwz     r11, 0(up)
 
55
        mtctr   n
 
56
        lis     r12, 0xAAAA
 
57
        ori     r12, r12, 0xAAAB
 
58
        li      r10, 3
 
59
 
 
60
        cmplw   cr7, cy, r11
 
61
        subf    r11, cy, r11
 
62
 
 
63
        mullw   r0, r11, r12
 
64
        stw     r0, 0(rp)
 
65
        bdz     L(one)
 
66
 
 
67
L(top): lwzu    r9, 4(up)
 
68
        mulhwu  r7, r0, r10
 
69
        bgt-    cr7, L(adj)             C very unlikely branch
 
70
L(bko): cmplw   cr7, r7, r9
 
71
        subf    r0, r7, r9
 
72
        mullw   r0, r12, r0
 
73
        stwu    r0, 4(rp)
 
74
        bdnz    L(top)
 
75
 
 
76
L(one): mulhwu  r3, r0, r10
 
77
        blelr+  cr7
 
78
        addi    r3, r3, 1
 
79
        blr
 
80
 
 
81
L(adj): addi    r7, r7, 1
 
82
        b       L(bko)
 
83
EPILOGUE()
 
84
ASM_END()