diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2021-10-28 13:31:17 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2021-10-29 10:31:56 -0400 |
commit | cb596fd43667f92c4cb037a4ee8b2061c393ba60 (patch) | |
tree | 77c58262cba2b191ffba14ee461ab4aee6a401a6 /gcc | |
parent | b8ef019ab938471f7f877a1eee3a6374fd8a6ae9 (diff) | |
download | gcc-cb596fd43667f92c4cb037a4ee8b2061c393ba60.zip gcc-cb596fd43667f92c4cb037a4ee8b2061c393ba60.tar.gz gcc-cb596fd43667f92c4cb037a4ee8b2061c393ba60.tar.bz2 |
Perform on-entry propagation after range_of_stmt on a gcond.
Propagation is automatically done by the temporal cache when defs are
out of date from the names on the RHS, but a gcond has no LHS, and any
updates on the RHS are never propagated. Always propagate them.
gcc/
PR tree-optimization/102983
* gimple-range-cache.h (propagate_updated_value): Make public.
* gimple-range.cc (gimple_ranger::range_of_stmt): Propagate exports
when processing gcond stmts.
gcc/testsuite/
* gcc.dg/pr102983.c: New.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-range-cache.h | 4 | ||||
-rw-r--r-- | gcc/gimple-range.cc | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr102983.c | 21 |
3 files changed, 34 insertions, 3 deletions
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 4937a0b..7510500 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -103,6 +103,8 @@ public: bool get_non_stale_global_range (irange &r, tree name); void set_global_range (tree name, const irange &r); + void propagate_updated_value (tree name, basic_block bb); + non_null_ref m_non_null; gori_compute m_gori; @@ -120,8 +122,6 @@ private: void entry_range (irange &r, tree expr, basic_block bb); void exit_range (irange &r, tree expr, basic_block bb); - void propagate_updated_value (tree name, basic_block bb); - bitmap m_propfail; vec<basic_block> m_workback; vec<basic_block> m_update_list; diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 91bacda..2c9715a 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -256,7 +256,17 @@ gimple_ranger::range_of_stmt (irange &r, gimple *s, tree name) // If no name, simply call the base routine. if (!name) - res = fold_range_internal (r, s, NULL_TREE); + { + res = fold_range_internal (r, s, NULL_TREE); + if (res && is_a <gcond *> (s)) + { + // Update any exports in the cache if this is a gimple cond statement. + tree exp; + basic_block bb = gimple_bb (s); + FOR_EACH_GORI_EXPORT_NAME (m_cache.m_gori, bb, exp) + m_cache.propagate_updated_value (exp, bb); + } + } else if (!gimple_range_ssa_p (name)) res = get_tree_range (r, name, NULL); // Check if the stmt has already been processed, and is not stale. diff --git a/gcc/testsuite/gcc.dg/pr102983.c b/gcc/testsuite/gcc.dg/pr102983.c new file mode 100644 index 0000000..ef58af6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr102983.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ +void foo(void); + +static int a = 1; + +int main() { + int c = 0; + for (int b = 0; b <= 0; b++) { + if (!a) + foo(); + if (b > c){ + if (c) + continue; + a = 0; + } + c = 1; + } +} + +/* { dg-final { scan-tree-dump-times "Folding predicate c_.* to 1" 1 "evrp" } } */ |