On Wed, Jun 3, 2026 at 4:16 AM Andrew Pinski <[email protected]> wrote: > > Currently if the ssa info (range or aliasing) is different > between the src and dest of a copy, sccopy will reject it. > This fixes the FIXME and handles it in a similar way as copyprop > handles it. This is needed to able to move sccopy earlier (before phiopt1) > and to act like a copyprop pass. > > Bootstrapped and tested on x86_64-linux-gnu with no regressions.
OK. > gcc/ChangeLog: > > * gimple-ssa-sccopy.cc (stmt_may_generate_copy): Remove restriction > on the ssa info being different for the "copy". > (scc_copy_prop::replace_scc_by_value): Call > maybe_duplicate_ssa_info_at_copy > when copyproping a ssa name. > > Signed-off-by: Andrew Pinski <[email protected]> > --- > gcc/gimple-ssa-sccopy.cc | 18 ++---------------- > 1 file changed, 2 insertions(+), 16 deletions(-) > > diff --git a/gcc/gimple-ssa-sccopy.cc b/gcc/gimple-ssa-sccopy.cc > index 0badfb11b93..4252e5295df 100644 > --- a/gcc/gimple-ssa-sccopy.cc > +++ b/gcc/gimple-ssa-sccopy.cc > @@ -405,22 +405,6 @@ stmt_may_generate_copy (gimple *stmt) > if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)) > return false; > > - /* It is possible that lhs has more alignment or value range information. > By > - propagating we would lose this information. So in the case that > alignment > - or value range information differs, we are conservative and do not > - propagate. > - > - FIXME: Propagate alignment and value range info the same way copy-prop > - does. */ > - if (POINTER_TYPE_P (TREE_TYPE (lhs)) > - && POINTER_TYPE_P (TREE_TYPE (rhs)) > - && SSA_NAME_PTR_INFO (lhs) != SSA_NAME_PTR_INFO (rhs)) > - return false; > - if (!POINTER_TYPE_P (TREE_TYPE (lhs)) > - && !POINTER_TYPE_P (TREE_TYPE (rhs)) > - && SSA_NAME_RANGE_INFO (lhs) != SSA_NAME_RANGE_INFO (rhs)) > - return false; > - > return true; /* A statement of type _2 = _1;. */ > } > > @@ -497,6 +481,8 @@ scc_copy_prop::replace_scc_by_value (vec<gimple *> scc, > tree val) > > } > replace_uses_by (name, val); > + if (TREE_CODE (val) == SSA_NAME) > + maybe_duplicate_ssa_info_at_copy (name, val); > bitmap_set_bit (dead_stmts, SSA_NAME_VERSION (name)); > didsomething = true; > } > -- > 2.43.0 >
