https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103168
Bug ID: 103168 Summary: Value numbering of pure functions can be improved Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- In the following testcase the call to test is loop invariant because memory modified is not escaping. While value numbering of pure functions we however add value number of the vdef corresponding to vuse. I think we want to walk the chain to aliasing store? __attribute__((const)) int test(); int main() { int ret; int a[10]; for (int i=0; i<10;i++) if (test()) a[i]++; for (int i=0; i<10;i++) ret *= a[i]; return ret; }