]> git.ipfire.org Git - thirdparty/gcc.git/commit
VN: Handle `(A CMP B) !=/== 0` for predicates [PR117414]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sat, 2 Nov 2024 06:12:52 +0000 (23:12 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Thu, 7 Nov 2024 16:24:52 +0000 (08:24 -0800)
commitadd4bb94459d6cecae11de279b49f9c1acb14394
treef8049d5475c188906028aef79633350b2290c979
parent578002846620ed04192a4832e9f20b5c32816153
VN: Handle `(A CMP B) !=/== 0` for predicates [PR117414]

After the last patch, we also want to record `(A CMP B) != 0`
as `(A CMP B)` and `(A CMP B) == 0` as `(A CMP B)` with the
true/false edges swapped.

This shows up more due to the new handling of
`(A | B) ==/!= 0` in insert_predicates_for_cond
as now we can notice these comparisons which were not seen before.

This is enough to fix the original issue in `gcc.dg/tree-ssa/pr111456-1.c`
and make sure we don't regress it when enhancing ifcombine.

This adds that predicate and allows us to optimize f
in fre-predicated-3.c.

Changes since v1:
* v2:  Use vn_valueize.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/117414

gcc/ChangeLog:

* tree-ssa-sccvn.cc (insert_predicates_for_cond): Handle `(A CMP B) !=/== 0`.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/fre-predicated-3.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/gcc.dg/tree-ssa/fre-predicated-3.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc