diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-08-30 21:21:01 -0700 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-08-31 23:57:24 -0700 |
commit | 3d86e7f4a8aef1b864a51660825597eafe9059b1 (patch) | |
tree | 4d16d3d84d91b1ff6d7e1e77bf124c1be5337a76 /libcpp | |
parent | 1967f21d000e09d3d3190317af7923b578ce02b1 (diff) | |
download | gcc-3d86e7f4a8aef1b864a51660825597eafe9059b1.zip gcc-3d86e7f4a8aef1b864a51660825597eafe9059b1.tar.gz gcc-3d86e7f4a8aef1b864a51660825597eafe9059b1.tar.bz2 |
MATCH [PR19832]: Optimize some `(a != b) ? a OP b : c`
This patch adds the following match patterns to optimize these:
/* (a != b) ? (a - b) : 0 -> (a - b) */
/* (a != b) ? (a ^ b) : 0 -> (a ^ b) */
/* (a != b) ? (a & b) : a -> (a & b) */
/* (a != b) ? (a | b) : a -> (a | b) */
/* (a != b) ? min(a,b) : a -> min(a,b) */
/* (a != b) ? max(a,b) : a -> max(a,b) */
/* (a != b) ? (a * b) : (a * a) -> (a * b) */
/* (a != b) ? (a + b) : (a + a) -> (a + b) */
/* (a != b) ? (a + b) : (2 * a) -> (a + b) */
Note currently only integer types (include vector types)
are handled. Floating point types can be added later on.
OK? Bootstrapped and tested on x86_64-linux-gnu.
The first pattern had still shows up in GCC in cse.c's preferable
function which was the original motivation for this patch.
PR tree-optimization/19832
gcc/ChangeLog:
* match.pd: Add pattern to optimize
`(a != b) ? a OP b : c`.
gcc/testsuite/ChangeLog:
* g++.dg/opt/vectcond-1.C: New test.
* gcc.dg/tree-ssa/phi-opt-same-1.c: New test.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions