match.pd: Simplify copysign (x, -x) to -x [PR96715]
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Aug 2020 05:21:26 +0000 (07:21 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 25 Aug 2020 05:21:26 +0000 (07:21 +0200)
commitbb5e895245ebef488b63efc239f64488aef65cf1
tree86b971ab006647bbc6f505b7b5cbbd517f2d30d3
parent61680cfaf1eef26a5953f36ab82a1cc13f9b2f2c
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.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/copy-sign-3.c [new file with mode: 0644]