[mips-gnu-discuss] IEEE math support

Martin Herrman martin at herrman.nl
Fri Sep 30 14:52:10 UTC 2011


2011/9/28 Joseph S. Myers <joseph at codesourcery.com>:

Hi Joseph,

thanks for your quick response.

> "supports IEEE math" can have many possible meanings; it's difficult to
> give a meaningful answer without a detailed explanation of the
> requirements of the particular code, but in general the support levels on
> i386 and MIPS are similar.

I think that I cannot be more specific than the test done in the
configure script:

int main(void){
    double rrdnan,rrdinf,rrdc,rrdzero;
    ;
    /* some math to see if we get a floating point exception */
    rrdzero=sin(0.0); /* don't let the compiler optimize us away */
    rrdnan=0.0/rrdzero; /* especially here */
    rrdinf=1.0/rrdzero; /* and here. I want to know if it can do the magic */
                  /* at run time without sig fpe */
    rrdc = rrdinf + rrdnan;
    rrdc = rrdinf / rrdnan;
    if (! isnan(rrdnan)) {printf ("not isnan(NaN) ... "); return 1;}
    if (rrdnan == rrdnan) {printf ("nan == nan ... "); return 1;}
    if (! isinf(rrdinf)) {printf ("not isinf(oo) ... "); return 1;}
    if (! isinf(-rrdinf)) {printf ("not isinf(-oo) ... "); return 1;}
    if (! rrdinf > 0) {printf ("not inf > 0 ... "); return 1;}
    if (! -rrdinf < 0) {printf ("not -inf < 0 ... "); return 1;}
    return 0;
 }

I could fake it by setting rc_cv_ieee_works before running configure:

if test x${rd_cv_ieee_works} = "xyes"; then
 { $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }

but I guess that this likely ends up in problems..

> The -mieee-fp option does very little on i386.  Within the compiler it's
> enabled by default, so the only effect is to link with -lieee at link
> time, and in turn what that does is disable setting errno for various
> mathematical library functions (but probably not consistently) while
> leaving them setting the exceptions they would do anyway.  Code using
> -mieee-fp on i386 is probably using it based on some vague idea that it
> sounds good, rather than because of any need for its actual, limited,
> effects.

Ah, I see, but don't understand the use of disable the setting of an
errno but still set an exception.

> You can always link with -lieee if the effects of that are genuinely
> required.  If your MIPS processor has hardware floating point support then
> you will have exceptions and rounding modes working (subject to all the
> same compiler limitations as apply on all targets, not just MIPS),
> although some exceptional cases may rely on kernel emulation.

This is the target platform CPU:

http://opensource.eminent-online.com/wiki/index.php/EM7075_Tech

I don't understand what you mean with "rounding modes". Although I do
have some basic knowledge on math and CPU architecture, I'm not an
expert at all in these fields.

Do you have any tips/solutions to get this source compiled?

Thanks a lot,

Martin


More information about the mips-gnu-discuss mailing list