https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118902
Bug ID: 118902 Summary: missing predicated VN due to Canonical order of comparison with invariant Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void foo(int); void l(int**); int f1(int j, int t) { int p = 0; int *a = &p; l(&a); if (a == &p) return 0; for(int i = 0; i < j; i++) { if (a == &p) foo(p); } return 0; } ``` We should be able to optimize out the call to foo because in the first iteration of the loop, a cannot be equal to `&p`. But we don't record the predicate VN because the comparison is: `&p == a.0_1`. The patch which I put in PR 118867 fixes this.