@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
(define_operator_list POW10 BUILT_IN_POW10F BUILT_IN_POW10 BUILT_IN_POW10L)
(define_operator_list SQRT BUILT_IN_SQRTF BUILT_IN_SQRT BUILT_IN_SQRTL)
(define_operator_list CBRT BUILT_IN_CBRTF BUILT_IN_CBRT BUILT_IN_CBRTL)
+(define_operator_list COS BUILT_IN_COS BUILT_IN_COSL BUILT_IN_COSF)
/* Simplifications of operations with one constant operand and
@@ -303,6 +304,11 @@ along with GCC; see the file COPYING3. If not see
(if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
@0)))
+/* Simplify cos (-x) -> cos (x). */
+(simplify
+ (COS (negate @0))
+ (COS @0))
+
/* X % Y is smaller than Y. */
(for cmp (lt ge)
(simplify
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-require-effective-target int32 } */
+
+#include <math.h>
+
+double t (double x)
+{
+ x = -x;
+ x = cos (x);
+ return x;
+}
+
+/* { dg-final { scan-tree-dump-not "-x" "optimized" } } */