1 dnl PPC
-32 mpn_divrem_2
-- Divide an mpn number by a normalized
2-limb number.
3 dnl Copyright
2007, 2008, 2012 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
10 dnl
* the GNU Lesser General
Public License as published by the Free
11 dnl Software Foundation
; either version 3 of the License, or (at your
12 dnl option
) any later version.
16 dnl
* the GNU General
Public License as published by the Free Software
17 dnl Foundation
; either version 2 of the License, or (at your option) any
20 dnl
or both
in parallel
, as here.
22 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
23 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
24 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
27 dnl You should have received copies of the GNU General
Public License
and the
28 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
29 dnl see
https://www.gnu.
org/licenses
/.
31 include(`..
/config.m4
')
46 C * Decrease register usage.
47 C * Make sure mul operands and optimal for early-out.
48 C * Check that things work well for a shared library build.
49 C * Write an invert_limb, perhaps inline, perhaps as a private call. Or at
50 C least vastly improve the current __udiv_qrnnd_c based code.
54 PROLOGUE(mpn_divrem_2)
59 addi r29, r5, -8 C up = up_param + un - 2
70 L(4): subfc r28, r7, r28
81 add r8, r8, r9 C rp += un + fn
88 rlwinm r5, r10, 0, 16, 31
99 addi r31, r31, -1 C q1--
102 addi r31, r31, -1 C q1--
104 L(9): subf r0, r6, r0
116 addi r6, r6, -1 C q0--
119 C add r0, r0, r10 C final remainder
120 addi r6, r6, -1 C q0--
121 L(13): rlwimi r6, r31, 16, 0, 15 C assemble final quotient
123 C Adjust di by including d0
124 mullw r9, r10, r6 C t0 = LO(di * d1)
127 mulhwu r9, r6, r7 C s1 = HI(di * d0)
131 L(18): subfc r9, r10, r9
137 C r0 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r28 r29 r30 r31
138 C msl di d0 qp d1 fn up un
140 mullw r0, r12, r6 C q0 = LO(n2 * di)
142 addc r31, r0, r28 C q0 += n1
143 mulhwu r9, r12, r6 C q = HI(n2 * di)
144 adde r12, r9, r12 C q += n2
146 mullw r0, r10, r12 C d1 * q
148 subf r0, r0, r28 C n1 -= d1 * q
152 L(23): mullw r11, r12, r7 C t0 = LO(d0 * q)
153 subfc r28, r7, r9 C n0 -= d0
154 subfe r0, r10, r0 C n1 -= d1
155 mulhwu r12, r12, r7 C t1 = HI(d0 * q)
156 subfc r28, r11, r28 C n0 -= t0
157 subfe r12, r12, r0 C n1 -= t1
163 L(24): cmplw cr7, r12, r10
165 L(bck): stw r5, 0(r8)
169 L(ret): stw r28, 0(r29)
175 L(fix): cmplw cr6, r28, r7
178 L(28): subfc r28, r7, r28