match.pd: Add (-(X < 0) | 1) * X -> abs (X) etc. simplifications [PR94785]
authorJakub Jelinek <jakub@redhat.com>
Thu, 31 Dec 2020 10:08:15 +0000 (11:08 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 31 Dec 2020 10:08:15 +0000 (11:08 +0100)
commit8f12ce2ea3be12de4f83d3c419bdb1dc5036b202
treeacdd88b6fe3f832de1cfc8febfc18dbf98a27043
parent9e603837f7ad886df62e02ac0cd395ec17b7d587
match.pd: Add (-(X < 0) | 1) * X -> abs (X) etc. simplifications [PR94785]

The following patch adds two simplifications to recognize idioms
for ABS_EXPR resp. ABSU_EXPR.

2020-12-31  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94785
* match.pd ((-(X < 0) | 1) * X -> abs (X)): New simplification.
((-(X < 0) | 1U) * X -> absu (X)): Likewise.

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