match.pd (copysign(x, CST) -> [-]abs (x)): New pattern.

2016-10-05  Richard Biener  <rguenther@suse.de>

	* match.pd (copysign(x, CST) -> [-]abs (x)): New pattern.

	* gcc.dg/fold-copysign-1.c: New testcase.

From-SVN: r240775
This commit is contained in:
Richard Biener 2016-10-05 11:34:58 +00:00 committed by Richard Biener
parent a5382f1c6b
commit eeb57981e2
4 changed files with 32 additions and 0 deletions

View File

@ -1,3 +1,7 @@
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

View File

@ -452,6 +452,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(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

View File

@ -1,3 +1,7 @@
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.

View File

@ -0,0 +1,16 @@
/* { 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" } } */