Question regarding libm
Jan-Benedict Glaw
jbglaw at lug-owl.de
Fri Sep 30 06:32:51 UTC 2005
On Fri, 2005-09-30 08:21:41 +0200, Jan-Benedict Glaw <jbglaw at lug-owl.de> wrote:
> Fortunately, it dies pretty early in _fpmaxtostr
>
>
> 12acf: 56 8f 00 00 cvtfd $0x00000000 [f-float],r0
> 12ad3: 00 00 50
> 12ad6: 71 56 50 cmpd r6,r0 test if (x == 0)
> 12ad9: 12 1c bneq 12af7 <_fpmaxtostr+0x85> if it's not, goto x_is_not_null
> die_here:
> ~~~~~~~~~
> 12adb: 67 8f 00 00 divd3 $0x0000000000000000 [d-float],$0x8 [d-float],r0
> 12adf: 00 00 00 00
> 12ae3: 00 00 08 50
>
> 0x67 = divd3 x, y, z (z = y/x, with D_floating values)
> 0x8f = immediate data following (a full D_floating value)
> 0x00 00 00 00 00 00 00 00 = D_floating value (divident)
> 0x08 = register deferred mode; a pointer to divisor (of type
> D_floating using 64bit representation) can be found in
> register R8
> 0x50 = Register mode; put the result into R0 (and R1, because it's
> 64 bits of data)
>
> The immediate D_floating value 0x0000000000000000 is actually, you
> already guess that, zero. So the compiler generates wrong code for
>
> if (x == 0) {
> #if 1
> if (zeroisnegative(x)) { <---- this
> *sign_str = '-';
> }
> #endif
> exp = -1;
> goto GENERATE_DIGITS;
> }
>
> zeroisnegative() is:
> #define zeroisnegative(x) ((1./(x)) < 0)
Actually, I was wrong and should better have had a good look at the
code.
if (x == 0) {
#if idiot_will_ignore_me_for_sure
if (1/x < 0) {
sign = '-'
}
#endif /* idiot_not_understanding_the_code */
exp = -1
goto OUT
}
At the point of zeroisnegative(), we already *know* that x == 0, so
the compiler isn't all that wrong generating some_value/0. I'm
actually not sure if we have a sign-attached null on VAXen, so the #if
1 ... #endif code block checking for a negative zero should probably
only be active if the target is known to have negative zeros...
Will a patch adding a config option for this be accepted?
MfG, JBG
--
Jan-Benedict Glaw jbglaw at lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20050930/95beaf27/attachment-0002.pgp
More information about the uClibc
mailing list