diff options
author | Richard Biener <rguenther@suse.de> | 2023-11-09 09:41:10 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-11-09 11:48:32 +0100 |
commit | 8ebcea91e24964ec52ca2caf9f8585f3a785f7d5 (patch) | |
tree | d9ab4a5e57fcda68b7116ac9466be0e821124caa /gcc/tree-ssa-sccvn.cc | |
parent | a0273d257ccf4d01997368d85f008094ab84db73 (diff) | |
download | gcc-8ebcea91e24964ec52ca2caf9f8585f3a785f7d5.zip gcc-8ebcea91e24964ec52ca2caf9f8585f3a785f7d5.tar.gz gcc-8ebcea91e24964ec52ca2caf9f8585f3a785f7d5.tar.bz2 |
tree-optimization/112444 - avoid bougs PHI value-numbering
With .DEFERRED_INIT ssa_undefined_value_p () can return true for
values we did not visit (because they proved unreachable) but
are not .VN_TOP. Avoid using those as value which, because they
are not visited, are assumed to be defined outside of the region.
PR tree-optimization/112444
* tree-ssa-sccvn.cc (visit_phi): Avoid using not visited
defs as undefined vals.
* gcc.dg/torture/pr112444.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-sccvn.cc')
-rw-r--r-- | gcc/tree-ssa-sccvn.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 0b2c10dc..11537fa 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -5911,6 +5911,7 @@ static bool visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p) { tree result, sameval = VN_TOP, seen_undef = NULL_TREE; + bool seen_undef_visited = false; tree backedge_val = NULL_TREE; bool seen_non_backedge = false; tree sameval_base = NULL_TREE; @@ -5941,10 +5942,12 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p) if (def == PHI_RESULT (phi)) continue; ++n_executable; + bool visited = true; if (TREE_CODE (def) == SSA_NAME) { + tree val = SSA_VAL (def, &visited); if (!backedges_varying_p || !(e->flags & EDGE_DFS_BACK)) - def = SSA_VAL (def); + def = val; if (e->flags & EDGE_DFS_BACK) backedge_val = def; } @@ -5956,7 +5959,16 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p) else if (TREE_CODE (def) == SSA_NAME && ! virtual_operand_p (def) && ssa_undefined_value_p (def, false)) - seen_undef = def; + { + if (!seen_undef + /* Avoid having not visited undefined defs if we also have + a visited one. */ + || (!seen_undef_visited && visited)) + { + seen_undef = def; + seen_undef_visited = visited; + } + } else if (sameval == VN_TOP) { sameval = def; |