diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2022-11-07 15:07:35 -0500 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2022-11-07 19:22:19 -0500 |
commit | c838119946c9f75f1e42f4320275355822cc86fc (patch) | |
tree | 2ca1a424406083b17d55461bfc69fc2a093c9d47 /gcc/gimple-range-cache.cc | |
parent | f8d901d00e94e5a03c3321b37303eddd7c321ecb (diff) | |
download | gcc-c838119946c9f75f1e42f4320275355822cc86fc.zip gcc-c838119946c9f75f1e42f4320275355822cc86fc.tar.gz gcc-c838119946c9f75f1e42f4320275355822cc86fc.tar.bz2 |
Add transitive inferred range processing.
Rewalk statements at the end of a block to see if any inferred ranges
affect earlier calculations and register those as inferred ranges.
gcc/
PR tree-optimization/104530
* gimple-range-cache.cc (ranger_cache::register_inferred_value):
New. Split from:
(ranger_cache::apply_inferred_ranges): Move setting cache to
separate function.
* gimple-range-cache.h (register_inferred_value): New prototype.
* gimple-range-infer.cc (infer_range_manager::has_range_p): New.
* gimple-range-infer.h (has_range_p): New prototype.
* gimple-range.cc (register_transitive_inferred_ranges): New.
* gimple-range.h (register_transitive_inferred_ranges): New proto.
* tree-vrp.cc (rvrp_folder::fold_stmt): Check for transitive inferred
ranges at the end of the block before folding final stmt.
gcc/testsuite/
* gcc.dg/pr104530.c: New.
Diffstat (limited to 'gcc/gimple-range-cache.cc')
-rw-r--r-- | gcc/gimple-range-cache.cc | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 89e2403..ce5a0c8 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -1544,8 +1544,27 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb, return true; } -// This routine is used during a block walk to move the state of non-null for -// any operands on stmt S to nonnull. +// This routine will register an inferred value in block BB, and possibly +// update the on-entry cache if appropriate. + +void +ranger_cache::register_inferred_value (const vrange &ir, tree name, + basic_block bb) +{ + Value_Range r (TREE_TYPE (name)); + if (!m_on_entry.get_bb_range (r, name, bb)) + exit_range (r, name, bb, RFD_READ_ONLY); + if (r.intersect (ir)) + { + m_on_entry.set_bb_range (name, bb, r); + // If this range was invariant before, remove invariance. + if (!m_gori.has_edge_range_p (name)) + m_gori.set_range_invariant (name, false); + } +} + +// This routine is used during a block walk to adjust any inferred ranges +// of operands on stmt S. void ranger_cache::apply_inferred_ranges (gimple *s) @@ -1574,17 +1593,6 @@ ranger_cache::apply_inferred_ranges (gimple *s) tree name = infer.name (x); m_exit.add_range (name, bb, infer.range (x)); if (update) - { - Value_Range r (TREE_TYPE (name)); - if (!m_on_entry.get_bb_range (r, name, bb)) - exit_range (r, name, bb, RFD_READ_ONLY); - if (r.intersect (infer.range (x))) - { - m_on_entry.set_bb_range (name, bb, r); - // If this range was invariant before, remove invariance. - if (!m_gori.has_edge_range_p (name)) - m_gori.set_range_invariant (name, false); - } - } + register_inferred_value (infer.range (x), name, bb); } } |