This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Strange math library results on i386-linux
- From: Roger Sayle <roger at eyesopen dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Brad Lucier <lucier at math dot purdue dot edu>, <gcc at gcc dot gnu dot org>
- Date: Tue, 10 Sep 2002 18:36:10 -0600 (MDT)
- Subject: Re: Strange math library results on i386-linux
On 11 Sep 2002, Gabriel Dos Reis wrote:
> Brad Lucier <lucier@math.purdue.edu> writes:
> | So now I see why -fno-math-errno and -funsafe-math-optimizations should
> | have associated DEFINEs. If there were -D__NO_MATH_ERRNO, then sqrt
> | could be inlined even if -D__NO_UNSAFE_MATH_OPTIMIZATIONS (since the
> | hardware sqrt is exact in IEEE 754 arithmetic implementations).
>
> It might be a good idea to conisder those defines for 3.4.
Whilst I have absolutely nothing against GCC defining __NO_MATH_ERRNO
and __NO_UNSAFE_MATH_OPTIMIZATIONS, I think that the best long term
solution is to let the compiler handle the libm functions as builtins
rather than have glibc's headers defining them as inline __asm__.
Currently GCC will inline "sqrt", "sin", "cos" etc... itself, but
can also perform other optimizations that are otherwise hidden
by glibc's definitions. For example, using "-fno-math-errno", the
expression "sqrt(x) + sqrt(x)" will call "sqrt" only once with
-D__NO_MATH_INLINES, but twice by default! Similar optimizations will
include evaluating functions with constant arguments at compile time,
"const double pi = 4.0*atan(1.0)", scheduling of instructions, etc...
I'd propose that once GCC knows how to inline an intrinsic itself,
the __asm__ form should eventually be removed from glibc's headers.
Roger
--