This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/79207] Special trigonometric simplification for solving cubics with -ffast-math


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

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