https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80215
Bug ID: 80215 Summary: VN has trouble with conditional equivalences (DOM/FRE) Product: gcc Version: 7.0.1 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- Currently DOM doesn't handle either redundancy in foo or bar while FRE only handles the first. int d, e; int foo (int a, int c) { e = a * c; if (a == c) return a * c; return 0; } int bar (int a, int c) { e = a * c; if (a == c) return c * c; return 0; } another example is int e; int baz (int a, int c) { e = a + c; if (a == c) return c + c; return 0; } with the additional complication of c + c -> 2 * c canonicalization. The issue is unifying of two values (plus eventual followup simplifications that might be possible). VN algorithms generally do not handle this well. For DOM-VRP I played with re-propagating starting from uses of the newly recorded equivalency.