diff options
author | Richard Biener <rguenther@suse.de> | 2023-07-17 12:15:29 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-07-20 14:45:46 +0200 |
commit | d0de3bf9175877d6c51c94fe04662c6e031876e1 (patch) | |
tree | 7834ae65fcedbe90cc7c56d577c504da291a5c49 | |
parent | c5bd0e5870aed178b7f82e7b94f59a383e7c5b4f (diff) | |
download | gcc-d0de3bf9175877d6c51c94fe04662c6e031876e1.zip gcc-d0de3bf9175877d6c51c94fe04662c6e031876e1.tar.gz gcc-d0de3bf9175877d6c51c94fe04662c6e031876e1.tar.bz2 |
tree-optimization/110204 - second level redundancy and simplification
When PRE discovers a full redundancy during insertion it cannot unite
the two value sets. Instead it inserts a copy old-val = new-val where
new-val can also be a constant. The following looks through such
copies during elimination, providing one extra level of constant and
copy propagation. For the PR this helps avoiding a bogus diagnostic
that's emitted on unreachable code during loop optimization.
PR tree-optimization/110204
* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
Look through copies generated by PRE.
-rw-r--r-- | gcc/tree-ssa-sccvn.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 11061a3..a0b98c1 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -6594,7 +6594,22 @@ eliminate_dom_walker::eliminate_avail (basic_block, tree op) if (SSA_NAME_IS_DEFAULT_DEF (valnum)) return valnum; if (avail.length () > SSA_NAME_VERSION (valnum)) - return avail[SSA_NAME_VERSION (valnum)]; + { + tree av = avail[SSA_NAME_VERSION (valnum)]; + /* When PRE discovers a new redundancy there's no way to unite + the value classes so it instead inserts a copy old-val = new-val. + Look through such copies here, providing one more level of + simplification at elimination time. */ + gassign *ass; + if (av && (ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (av)))) + if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS) + { + tree rhs1 = gimple_assign_rhs1 (ass); + if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME) + av = rhs1; + } + return av; + } } else if (is_gimple_min_invariant (valnum)) return valnum; |