diff options
author | Richard Biener <rguenther@suse.de> | 2021-01-04 13:02:24 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-01-04 13:51:56 +0100 |
commit | 39bd65faee3bafe2dc067e5fedb5079896551a8a (patch) | |
tree | 9da1da01aeca091cfad6664b0490ed8c03da488c /gcc/tree-ssa-sccvn.c | |
parent | 7f2b73175666f678adbf007907c7aa2661284bd3 (diff) | |
download | gcc-39bd65faee3bafe2dc067e5fedb5079896551a8a.zip gcc-39bd65faee3bafe2dc067e5fedb5079896551a8a.tar.gz gcc-39bd65faee3bafe2dc067e5fedb5079896551a8a.tar.bz2 |
tree-optimization/98464 - replace loop info with avail at uses
This does VN replacement in loop nb_iterations consistent with
the rest of the IL by using availability at the definition site
of uses.
2021-01-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/98464
* tree-ssa-sccvn.c (vn_valueize_for_srt): Rename from ...
(vn_valueize_wrapper): ... this. Temporarily adjust vn_context_bb.
(process_bb): Adjust.
* g++.dg/opt/pr98464.C: New testcase.
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 19defc0..1701685 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -304,12 +304,23 @@ static vn_nary_op_t last_inserted_nary; static vn_tables_t valid_info; -/* Valueization hook. Valueize NAME if it is an SSA name, otherwise - just return it. */ +/* Valueization hook for simplify_replace_tree. Valueize NAME if it is + an SSA name, otherwise just return it. */ tree (*vn_valueize) (tree); -tree vn_valueize_wrapper (tree t, void* context ATTRIBUTE_UNUSED) -{ - return vn_valueize (t); +static tree +vn_valueize_for_srt (tree t, void* context ATTRIBUTE_UNUSED) +{ + basic_block saved_vn_context_bb = vn_context_bb; + /* Look for sth available at the definition block of the argument. + This avoids inconsistencies between availability there which + decides if the stmt can be removed and availability at the + use site. The SSA property ensures that things available + at the definition are also available at uses. */ + if (!SSA_NAME_IS_DEFAULT_DEF (t)) + vn_context_bb = gimple_bb (SSA_NAME_DEF_STMT (t)); + tree res = vn_valueize (t); + vn_context_bb = saved_vn_context_bb; + return res; } @@ -6995,7 +7006,7 @@ process_bb (rpo_elim &avail, basic_block bb, if (bb->loop_father->nb_iterations) bb->loop_father->nb_iterations = simplify_replace_tree (bb->loop_father->nb_iterations, - NULL_TREE, NULL_TREE, &vn_valueize_wrapper); + NULL_TREE, NULL_TREE, &vn_valueize_for_srt); } /* Value-number all defs in the basic-block. */ |