diff options
author | Sam Feifer <sfeifer@redhat.com> | 2022-07-21 16:31:41 -0400 |
---|---|---|
committer | Sam Feifer <sfeifer@redhat.com> | 2022-07-21 17:24:06 -0400 |
commit | 633e9920589ddfaf2d6da1c24ce99b18a2638db4 (patch) | |
tree | cc5b54b570daae95424bad5f4c2164020cb5052e /gcc/graphds.cc | |
parent | 28be481cf47d52af8b11972d2394226bbaf87867 (diff) | |
download | gcc-633e9920589ddfaf2d6da1c24ce99b18a2638db4.zip gcc-633e9920589ddfaf2d6da1c24ce99b18a2638db4.tar.gz gcc-633e9920589ddfaf2d6da1c24ce99b18a2638db4.tar.bz2 |
match.pd: Add new abs pattern [PR94920]
This patch is intended to fix a missed optimization in match.pd. It optimizes (x >= 0 ? x : 0) + (x <= 0 ? -x : 0) to just abs(x). Additionally, the pattern (x <= 0 ? -x : 0) now gets optimized to max(-x, 0), which helps with the other simplification rule.
Tests are also included to be added to the testsuite.
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
PR tree-optimization/94920
gcc/ChangeLog:
* match.pd (x >= 0 ? x : 0) + (x <= 0 ? -x : 0): New simplification.
(x <= 0 ? -x : 0): New simplification.
gcc/testsuite/ChangeLog:
* g++.dg/pr94920-1.C: New test.
* g++.dg/pr94920.C: New test.
* gcc.dg/pr94920-2.c: New test.
Diffstat (limited to 'gcc/graphds.cc')
0 files changed, 0 insertions, 0 deletions