+2016-10-05 Richard Biener <rguenther@suse.de>
+
+ * match.pd (copysign(x, CST) -> [-]abs (x)): New pattern.
+
2016-10-05 Richard Biener <rguenther@suse.de>
PR middle-end/77842
(hypots @0 (copysigns @1 @2))
(hypots @0 @1)))
+/* copysign(x, CST) -> [-]abs (x). */
+(for copysigns (COPYSIGN)
+ (simplify
+ (copysigns @0 REAL_CST@1)
+ (if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (@1)))
+ (negate (abs @0))
+ (abs @0))))
+
/* copysign(copysign(x, y), z) -> copysign(x, z). */
(for copysigns (COPYSIGN)
(simplify
+2016-10-05 Richard Biener <rguenther@suse.de>
+
+ * gcc.dg/fold-copysign-1.c: New testcase.
+
2016-10-05 Andreas Schwab <schwab@suse.de>
* g++.dg/pr49847-2.C: Remove.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-cddce1" } */
+
+double foo (double x)
+{
+ double one = 1.;
+ return __builtin_copysign (x, one);
+}
+double bar (double x)
+{
+ double minuszero = -0.;
+ return __builtin_copysign (x, minuszero);
+}
+
+/* { dg-final { scan-tree-dump-times "= -" 1 "cddce1" } } */
+/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 2 "cddce1" } } */