On Fri, Aug 7, 2015 at 10:55 AM, Uros Bizjak <ubiz...@gmail.com> wrote: > Hello! > >> Please find attached the patch "pr16107.patch" that converts the >> pattern:-cos (-x) -> cos (x) >> Please review and let me know if its okay. > > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-optimized" } */ > +/* { dg-require-effective-target int32 } */ > > There are no integers in the testcase.
Ok with the int32 target removed and also handling abs like (for op (negate abs) (for cos (COS) (cos (op @0)) (cos @0))) you can also do abs as a followup if you like. Btw, with this (IMHO) fold_builtin_cos/cosh can be reduced to constant folding, thus remove their fold_strip_sign_nops () path. Thanks, Richard. > Uros. > > +#include <math.h> > + > +double t (double x) > +{ > + x = -x; > + x = cos (x); > + return x; > +} > + > +/* { dg-final { scan-tree-dump-not "-x" "optimized" } } */