match.pd: Optimize ~(~X +- Y) into (X -+ Y) [PR94921]
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 May 2020 09:20:20 +0000 (11:20 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 6 May 2020 09:20:20 +0000 (11:20 +0200)
commita7b76d574b19190da190a60c065f347f40bab59e
tree5302a249505a7b87485ecd073d9150dabf6e1cd5
parent380a681518c3b387476be1064097f24b0847726d
match.pd: Optimize ~(~X +- Y) into (X -+ Y) [PR94921]

According to my verification proglet, this transformation for signed types
with undefined overflow doesn't introduce nor remove any UB cases, so should
be valid even for signed integral types.
Not using a for because of the :c on plus which can't be there on minus.

2020-05-06  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94921
* match.pd (~(~X - Y) -> X + Y, ~(~X + Y) -> X - Y): New
simplifications.

* gcc.dg/tree-ssa/pr94921.c: New test.
gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr94921.c [new file with mode: 0644]