This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]