This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/79207] Special trigonometric simplification for solving cubics with -ffast-math
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Jan 2017 17:09:38 +0000
- Subject: [Bug tree-optimization/79207] Special trigonometric simplification for solving cubics with -ffast-math
- Auto-submitted: auto-generated
- References: <bug-79207-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79207
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
It's hardly specific to those arguments. Any case of two or more calls of
(sin or cos) (+/- x + constant) for same x, possibly different constant,
could be converted (given -funsafe-math-optimizations) to sincos plus
multiplications by constants (i.e. by +/- sin and cos of the constant part
of the argument in the original call) and additions. (You also need
-funsafe-math-optimizations to convert the example
cos((alpha+2*M_PI)*ONETHIRD) into cos(alpha*ONETHIRD+2*M_PI*ONETHIRD) to
get all three expressions using the same x.)
(This is not an assertion of whether or not such a transformation is a
good idea, simply that the transformation is generic for arbitrary
constants. It may be that recognizing particular constants helps you get
a form like
> ret[1] = -0.5 * (t_ss3 + t_cos);
> ret[2] = 0.5 * (t_ss3 - t_cos);
rather than something more complicated where there are four slightly
different constants multiplied by the outputs of sincos.)