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;