https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93891
Bug ID: 93891 Summary: CSE where clobber writes the same value Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- void f(int**p,int**q){ ++**p; *q=*p; --**p; } produces _1 = *p_8(D); _2 = *_1; _3 = _2 + 1; *_1 = _3; *q_10(D) = _1; _4 = *p_8(D); etc where we do not CSE _4 -> _1. We do have code in vn_reference_lookup_3 to handle this kind of thing, look past a potential clobber, and ignore it if we find the same value. But for this test, vn_reference_lookup_2 returns 0 and we never look further than *q=1 when we valueize *p for _4. If we did, I expect we would skip *_1=3 using TBAA and eventually find _1=*p, which matches the potential clobber. (this comes from the same code as PR 93745 but should not have the same issue)