diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-09-05 12:44:41 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-09-05 13:43:51 +0200 |
commit | 90ef15352701c6880faee83a46031d7837ab9d27 (patch) | |
tree | e18207c6fd09f3dd67335e1a264e5fdb236993c3 /gcc/tree-ssa-threadbackward.c | |
parent | cbeeadff4c041c09a6335105d596019b6d583880 (diff) | |
download | gcc-90ef15352701c6880faee83a46031d7837ab9d27.zip gcc-90ef15352701c6880faee83a46031d7837ab9d27.tar.gz gcc-90ef15352701c6880faee83a46031d7837ab9d27.tar.bz2 |
Add an unreachable_path_p method to path_range_query.
Keeping track of unreachable calculations while traversing a path is
useful to determine edge reachability, among other things. We've been
doing this ad-hoc in the backwards threader, so this provides a cleaner
way of accessing the information.
This patch also makes it easier to compare different threading
implementations, in some upcoming work. For example, it's currently
difficult to gague how good we're doing compared to the forward threader,
because it can thread paths that are obviously unreachable. This
provides a way of discarding those paths.
Note that I've opted to keep unreachable_path_p() out-of-line, because I
have local changes that will enhance this method.
Tested on x86-64 Linux.
gcc/ChangeLog:
* gimple-range-path.cc (path_range_query::range_of_expr): Set
m_undefined_path when appropriate.
(path_range_query::internal_range_of_expr): Copy from range_of_expr.
(path_range_query::unreachable_path_p): New.
(path_range_query::precompute_ranges): Set m_undefined_path.
* gimple-range-path.h (path_range_query::unreachable_path_p): New.
(path_range_query::internal_range_of_expr): New.
* tree-ssa-threadbackward.c (back_threader::find_taken_edge_cond):
Use unreachable_path_p.
Diffstat (limited to 'gcc/tree-ssa-threadbackward.c')
-rw-r--r-- | gcc/tree-ssa-threadbackward.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 6827d00..449232c 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -213,20 +213,14 @@ edge back_threader::find_taken_edge_cond (const vec<basic_block> &path, gcond *cond) { - m_solver.precompute_ranges (path, m_imports); - - // Check if either operand is unreachable since this knowledge could - // help the caller cut down the search space. int_range_max r; - m_solver.range_of_expr (r, gimple_cond_lhs (cond)); - if (r.undefined_p ()) - return UNREACHABLE_EDGE; - m_solver.range_of_expr (r, gimple_cond_rhs (cond)); - if (r.undefined_p ()) - return UNREACHABLE_EDGE; + m_solver.precompute_ranges (path, m_imports); m_solver.range_of_stmt (r, cond); + if (m_solver.unreachable_path_p ()) + return UNREACHABLE_EDGE; + int_range<2> true_range (boolean_true_node, boolean_true_node); int_range<2> false_range (boolean_false_node, boolean_false_node); |