------- Comment #30 from rguenth at gcc dot gnu dot org 2009-12-14 11:23 ------- I fail to see why FRE does not remove the redundant load of *n_9(D). Oh, it is because we first value-number D.1537_58 = *n_9(D); and only after it we value-number D.1529_45 = *n_9(D);
This is because while we visit the SCC members in RPO order we do not impose any order on visiting SCCs and those two stmts are not dependent on each other (we neither account for virtual operands nor control dependences there). Old problem. The fix for this is to either wait for the VN rewrite or to collect all SCCs, sort them in RPO order and only then process them. Note that it still can be difficult to impose a total ordering on SCCs (but at least this case should be easy). Another possibility is to artificially grow SCCs and their dependencies by honoring dominating virtual operand uses, not only defs (ugh). For non-memory the missing ordering is not a problem as we do not rely on walking stmts during expression lookup (and that walking only visits dominating expressions). Something to keep in mind for the VN re-implementation as well. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42108