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: Brad Lucier <lucier at math dot purdue dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 9 Jun 2003 17:32:08 -0600 (MDT)
- Subject: Re: [PATCH] Some more trigonometric optimizations
Hi Brad,
> > -sin(x) = sin(-x)
> > -tan(x) = tan(-x)
> > -atan(x) = atan(-x)
>
> I suppose moving the minus signs outside the argument make these
> expressions more canonical somehow?
We move the negation inside if negate_expr_p determines that the
argument is "cheap" to negate, i.e. -sin(-x) becomes sin(x) and
-sin(a-b) becomes sin(b-a), but in general we won't be moving the
negation around arbitrarily.
> > sin(x)/cos(x) = tan(x)
> > cos(x)/sin(x) = 1.0/tan(x)
> > tan(x)*cos(x) = sin(x)
> > cos(x)*tan(x) = sin(x)
> > sin(x)/tan(x) = cos(x)
> > tan(x)/sin(x) = 1.0/cos(x)
>
> they're OK, I guess for unsafe-math-optimizations.
Many thanks for double checking.
Roger
--