diff options
author | Richard Biener <rguenther@suse.de> | 2016-10-05 11:34:58 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-10-05 11:34:58 +0000 |
commit | eeb57981e2d639f144ee6264fdc2bf6f23f8508b (patch) | |
tree | 67b02b7097aa4094b477c7958e05d2e179671a19 /gcc/match.pd | |
parent | a5382f1c6b729ce1cce0c76db8139f4dbe3caae7 (diff) | |
download | gcc-eeb57981e2d639f144ee6264fdc2bf6f23f8508b.zip gcc-eeb57981e2d639f144ee6264fdc2bf6f23f8508b.tar.gz gcc-eeb57981e2d639f144ee6264fdc2bf6f23f8508b.tar.bz2 |
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
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 067e667..e4b5d4d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -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 |