This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Some more trigonometric optimizations
- From: Roger Sayle <roger at eyesopen dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Brad Lucier <lucier at math dot purdue dot edu>, <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 10 Jun 2003 09:00:45 -0600 (MDT)
- Subject: Re: [PATCH] Some more trigonometric optimizations
On Mon, 9 Jun 2003, Richard Henderson wrote:
> Ok.
Many thanks. I hope its OK but the version that I checked in
didn't include the following two transformations:
sin(x)/tan(x) = cos(x)
tan(x)/sin(x) = 1.0/cos(x)
As Brad pointed out, these transformations have singularities
when x = 0.0. sin(0.0) = tan(0.0) = 0.0, so the above expressions
reduce to 0.0/0.0, which evaluates to NaN using IEEE semantics,
but our transformation converts that point into cos(0.0) = 1.0.
As Brad commented, removing this singularity is probably not
unreasonable with -ffast-math, but after struggling with it for
a day or two, I'm happier that we just don't perform that
transformation at all. It shouldn't have triggered very often,
and removing this borderline case reduces the size of the code.
The reduced patch was bootstraped and regression tested on
i686-pc-linux-gnu, with no new failures before I checked it in.
I hope this is OK with everyone? If anyone knows of a critical
piece of software or benchmark that would benefit from this
optimization, or a commercial compiler that performs it, let me
know and I'll reconsider.
Many thanks again.
Roger
--