another IEE related problem

Ulrich Drepper drepper@ipd.info.uni-karlsruhe.de
Wed Nov 19 19:21:00 GMT 1997


Hi,

Compiling this little piece of code on a ix86 machine

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern inline float
bar (float x)
{
  float res;
  asm ("fsqrt" : "=t" (res) : "0" (x));
  return res;
}
extern float fabsf (float);

float
foo (float x)
{
  float res = fabsf (bar (x));
  return res;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The generated code with -O3 -momit-leaf-frame-pointer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo:
        flds 4(%esp)
#APP
        fsqrt
#NO_APP
        ret
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is wrong.  In the real code I added the `fabs' in full knowledge
of the situation.  The problem is that according to IEEE

	sqrt(-0.0) == -0.0

and so I get a wrong result.  I don't know why gcc thinks the
fabs call is redundant (it should not be able to analyze the asm
statement) but in any case it is plainly wrong.

Another bug preventing the glibc test suite to be passed.

-- Uli
---------------.      drepper at gnu.org  ,-.   Rubensstrasse 5
Ulrich Drepper  \    ,-------------------'   \  76149 Karlsruhe/Germany
Cygnus Solutions `--' drepper at cygnus.com   `------------------------



More information about the Gcc mailing list