Skip to content

Commit

Permalink
tree-optimization/110204 - second level redundancy and simplification
Browse files Browse the repository at this point in the history
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.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

Richard.

	PR tree-optimization/110204
	* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
	Look through copies generated by PRE.
  • Loading branch information
rguenth authored and ouuleilei-bot committed Jul 20, 2023
1 parent c2d62cd commit 6d3f47c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gcc/tree-ssa-sccvn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6d3f47c

Please sign in to comment.