1 /* Copyright (C) 1996-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson <rth@tamu.edu>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
58 _ITOFT2 X, $f0, 0, Y, $f1, 8
66 /* Check to see if X fit in the double as an exact value. */
72 /* If we get here, we're expecting exact results from the division.
73 Do nothing else besides convert and clean up. */
94 /* If we get here, X is large enough that we don't expect exact
95 results, and neither X nor Y got mis-translated for the fp
96 division. Our task is to take the fp result, figure out how
97 far it's off from the correct result and compute a fixup. */
99 #define Q v0 /* quotient */
100 #define R t0 /* remainder */
101 #define SY t1 /* scaled Y */
102 #define S t2 /* scalar */
103 #define QY t3 /* Q*Y */
105 /* The fixup code below can only handle unsigned values. */
136 /* The quotient that we computed was too large. We need to reduce
137 it by S such that Y*S >= R. Obviously the closer we get to the
138 correct value the better, but overshooting high is ok, as we'll
139 fix that up later. */
153 /* The quotient that we computed was too small. Divide Y by the
154 current remainder (R) and add that to the existing quotient (Q).
155 The expectation, of course, is that R is much smaller than X. */
156 /* Begin with a shift-up loop. Compute S such that Y*S >= R. We
157 already have a copy of Y in SY and the value 1 in S. */
165 /* Shift-down and subtract loop. Each iteration compares our scaled
166 Y (SY) with the remainder (R); if SY <= R then X is divisible by
167 Y's scalar (S) so add it to the quotient (Q). */
182 /* If we got here, then X|Y is negative. Need to adjust everything
183 such that we're doing unsigned division in the fixup loop. */
184 /* T5 is true if result should be negative. */
195 blbc t5, $fix_sign_in_ret1
217 weak_alias (ldiv, lldiv)
218 weak_alias (ldiv, imaxdiv)