http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57303
--- Comment #9 from Marc Glisse <glisse at gcc dot gnu.org> --- (In reply to rguent...@suse.de from comment #7) > On Mon, 20 May 2013, glisse at gcc dot gnu.org wrote: > > + /* Remove *p = *p. */ > > + if (!inplace && TREE_CODE_CLASS (subcode) == tcc_reference > > + && operand_equal_p (lhs, gimple_assign_rhs1 (stmt), 0)) > > + { > > + gsi_remove (gsi, true); > > + return true; > > + } > > The obvious place would be dead store elimination. But beware that > the above, if not _literally_ being *p = *p can be changing the > effective type of the memory location and thus might be not dead > in terms of type-based aliasing rules (which basically means that > we need to do sth more clever than just removing the store). So operand_equal_p on a tcc_reference is not enough? Aliasing is complicated, I guess I'll open a PR about this optimization.