]> git.ipfire.org Git - thirdparty/gcc.git/commit
Match: Add pattern for `(a ? b : 0) | (a ? 0 : c)` into `a ? b : c` [PR103660]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 13 Aug 2024 00:37:32 +0000 (17:37 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 Aug 2024 13:59:15 +0000 (06:59 -0700)
commiteface71c18caea3009ddc1ac624cb41647e9d5c4
tree4e270e8bbf57942f4290c026be6df17ae459a063
parentb73373520f0ed5d131d2cd6ee9078939a98d7a0d
Match: Add pattern for `(a ? b : 0) | (a ? 0 : c)` into `a ? b : c` [PR103660]

This adds a pattern to convert `(a ? b : 0) | (a ? 0 : c)` into `a ? b : c`
which is simplier. It adds both for cond and vec_cond; even though vec_cond is
handled via a different pattern currently but requires extra steps for matching
so this should be slightly faster.

Also handle it for xor and plus too since those can be handled the same way.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/103660

gcc/ChangeLog:

* match.pd (`(a ? b : 0) | (a ? 0 : c)`): New pattern.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr103660-4.C: New test.
* gcc.dg/tree-ssa/pr103660-4.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/match.pd
gcc/testsuite/g++.dg/tree-ssa/pr103660-4.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr103660-4.c [new file with mode: 0644]