]> git.ipfire.org Git - thirdparty/gcc.git/commit
Reset relations when crossing backedges.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 20 Jan 2022 09:28:26 +0000 (10:28 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Fri, 21 Jan 2022 10:19:07 +0000 (11:19 +0100)
commiteb5ee6464809e051e0292471597931a660485658
tree6c6e3f240670f06d426fed1c8da1266618a4415d
parentc2d9159717b474f9c06dde4d32b48b87164deb50
Reset relations when crossing backedges.

As discussed in PR103721, the problem here is that we are crossing a
backedge and causing us to use relations from a previous iteration of a
loop.

This handles the testcases in both PR103721 and PR104067 which are variants
of the same thing.

Tested on x86-64 Linux with the usual regstrap as well as verifying the
thread count before and after the patch.  The number of threads is
reduced by a miniscule amount.

gcc/ChangeLog:

PR tree-optimization/103721
* gimple-range-path.cc
(path_range_query::relations_may_be_invalidated): New.
(path_range_query::compute_ranges_in_block): Reset relations if
they may be invalidated.
(path_range_query::maybe_register_phi_relation): Exit if relations
may be invalidated on incoming edge.
(path_range_query::compute_phi_relations): Pass incoming PHI edge
to maybe_register_phi_relation.
* gimple-range-path.h (relations_may_be_invalidated): New.
(maybe_register_phi_relation): Pass edge instead of tree.
* tree-ssa-threadbackward.cc (back_threader::back_threader):
Mark DFS edges.
* value-relation.cc (path_oracle::path_oracle): Call
mark_dfs_back_edges.
(path_oracle::register_relation): Add SSA names to m_registered
bitmap.
(path_oracle::reset_path): Clear m_registered bitmap.
* value-relation.h (path_oracle::set_root_oracle): New.

gcc/testsuite/ChangeLog:

* gcc.dg/pr103721-2.c: New test.
* gcc.dg/pr103721.c: New test.
gcc/gimple-range-path.cc
gcc/gimple-range-path.h
gcc/testsuite/gcc.dg/pr103721-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr103721.c [new file with mode: 0644]
gcc/tree-ssa-threadbackward.cc
gcc/value-relation.cc
gcc/value-relation.h