diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-08-25 07:21:26 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-08-25 07:21:26 +0200 |
commit | bb5e895245ebef488b63efc239f64488aef65cf1 (patch) | |
tree | 86b971ab006647bbc6f505b7b5cbbd517f2d30d3 /gcc/match.pd | |
parent | 61680cfaf1eef26a5953f36ab82a1cc13f9b2f2c (diff) | |
download | gcc-bb5e895245ebef488b63efc239f64488aef65cf1.zip gcc-bb5e895245ebef488b63efc239f64488aef65cf1.tar.gz gcc-bb5e895245ebef488b63efc239f64488aef65cf1.tar.bz2 |
match.pd: Simplify copysign (x, -x) to -x [PR96715]
The following patch implements an optimization suggested in the PR,
copysign(x,-x) can be optimized into -x (even without -ffast-math,
should work fine even for signed zeros and infinities or nans).
2020-08-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96715
* match.pd (copysign(x,-x) -> -x): New simplification.
* gcc.dg/tree-ssa/copy-sign-3.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 2cffcae..6e45836 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5294,6 +5294,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) @0) (simplify + /* copysign(x,-x) -> -x. */ + (COPYSIGN_ALL @0 (negate@1 @0)) + @1) + +(simplify /* copysign(x,y) -> fabs(x) if y is nonnegative. */ (COPYSIGN_ALL @0 tree_expr_nonnegative_p@1) (abs @0)) |