https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86829
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization, patch Status|UNCONFIRMED |NEW Last reconfirmed| |2018-08-02 CC| |rguenth at gcc dot gnu.org Version|unknown |9.0 Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- + /* Simplify sin(atan(x)) -> x / sqrt(x*x + 1). */ + (for sins (SIN) + atans (ATAN) + sqrts (SQRT) + (simplify + (sins (atans @0)) + (rdiv @0 ( sqrts (plus (mult @0 @0) + { build_one_cst (float_type_node);}))))) + + + /* Simplify cos(atan(x)) -> 1 / sqrt(x*x + 1). */ + (for coss (COS) + atans (ATAN) + sqrts (SQRT) + (simplify + (coss (atans @0)) + (rdiv { build_one_cst (float_type_node);} + ( sqrts (plus (mult @0 @0) { build_one_cst (float_type_node);}))))) likely happens because you use float_type_node instead of 'type' for build_one_cst. I think that if the atan intermediate result has additional uses then the substitution may not be beneficial? Thus you should write (atans:s @0) in both places. Otherwise this looks OK. Can you please post the patch to gcc-patches and add testcases?