]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: Simplify (a ? x : y) eq/ne (b ? x : y) [PR111150]
authorEikansh Gupta <quic_eikagupt@quicinc.com>
Wed, 22 May 2024 17:58:48 +0000 (23:28 +0530)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 17 Jul 2024 16:58:11 +0000 (09:58 -0700)
commit44fcc1ca11e7ea35dc9fb25a5317346bc1eaf7b2
tree2693948e2eb5da4739d727315a7e0423a8eda56d
parent7c3287f3613210d4f98c8095bc739bea6582bfbb
MATCH: Simplify (a ? x : y) eq/ne (b ? x : y) [PR111150]

This patch adds match pattern for `(a ? x : y) eq/ne (b ? x : y)`.
In forwprop1 pass, depending on the type of `a` and `b`, GCC produces
`vec_cond` or `cond_expr`. Based on the observation that `(x != y)` is
TRUE, the pattern can be optimized to produce `(a^b ? TRUE : FALSE)`.

The patch adds match pattern for a, b:
(a ? x : y) != (b ? x : y) --> (a^b) ? TRUE  : FALSE
(a ? x : y) == (b ? x : y) --> (a^b) ? FALSE : TRUE
(a ? x : y) != (b ? y : x) --> (a^b) ? TRUE  : FALSE
(a ? x : y) == (b ? y : x) --> (a^b) ? FALSE : TRUE

PR tree-optimization/111150

gcc/ChangeLog:

* match.pd (`(a ? x : y) eq/ne (b ? x : y)`): New pattern.
(`(a ? x : y) eq/ne (b ? y : x)`): New pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr111150.c: New test.
* gcc.dg/tree-ssa/pr111150-1.c: New test.
* g++.dg/tree-ssa/pr111150.C: New test.

Signed-off-by: Eikansh Gupta <quic_eikagupt@quicinc.com>
gcc/match.pd
gcc/testsuite/g++.dg/tree-ssa/pr111150.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr111150-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr111150.c [new file with mode: 0644]