diff options
author | Richard Biener <rguenther@suse.de> | 2021-12-07 11:13:39 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-12-07 14:07:40 +0100 |
commit | 6e8a31275fda445fb3e8d98e53f5e1541f4727af (patch) | |
tree | 342d6984b35acf0f217c7ae5ad998a2f5c0bda78 /gcc/tree-ssa-sccvn.c | |
parent | c93e704b9e0411f1db031df9716b9958307590e3 (diff) | |
download | gcc-6e8a31275fda445fb3e8d98e53f5e1541f4727af.zip gcc-6e8a31275fda445fb3e8d98e53f5e1541f4727af.tar.gz gcc-6e8a31275fda445fb3e8d98e53f5e1541f4727af.tar.bz2 |
tree-optimization/103596 - fix missed propagation into switches
may_propagate_copy unnecessarily restricts propagating non-abnormals
into places that currently contain an abnormal SSA name but are
not the PHI argument for an abnormal edge. This causes VN to
not elide a CFG path that it assumes is elided, resulting in
released SSA names in the IL.
The fix is to enhance the may_propagate_copy API to specify the
destination is _not_ a PHI argument. I chose to not update only
the relevant caller in VN and the may_propagate_copy_into_stmt API
at this point because this is a regression and needs backporting.
2021-12-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/103596
* tree-ssa-sccvn.c (eliminate_dom_walker::eliminate_stmt):
Note we are not propagating into a PHI argument to may_propagate_copy.
* tree-ssa-propagate.h (may_propagate_copy): Add
argument specifying whether we propagate into a PHI arg.
* tree-ssa-propagate.c (may_propagate_copy): Likewise.
When not doing so we can replace an abnormal with
something else.
(may_propagate_into_stmt): Update may_propagate_copy calls.
(replace_exp_1): Move propagation checking code to
propagate_value and rename to ...
(replace_exp): ... this and elide previous wrapper.
(propagate_value): Perform checking with adjusted
may_propagate_copy call and dispatch to replace_exp.
* gcc.dg/torture/pr103596.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index d31bf32..16c93d1 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -6607,7 +6607,7 @@ eliminate_dom_walker::eliminate_stmt (basic_block b, gimple_stmt_iterator *gsi) at the definition are also available at uses. */ sprime = eliminate_avail (gimple_bb (SSA_NAME_DEF_STMT (use)), use); if (sprime && sprime != use - && may_propagate_copy (use, sprime) + && may_propagate_copy (use, sprime, true) /* We substitute into debug stmts to avoid excessive debug temporaries created by removed stmts, but we need to avoid doing so for inserted sprimes as we never want |