http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57742
--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> --- (In reply to Richard Biener from comment #5) > We have walk_aliased_vdefs for this. Basically the first callback > you receive has to be the malloc, otherwise there is an aliasing > stmt inbetween. Cool! Last time I looked into a similar optimization, I needed to look also at the memory reads, not just the writes, so it was significantly more complicated. walk_aliased_vdefs looks perfect here, both for malloc+memset where there is nothing to read before the memset, and for calloc+memset where reading before or after the memset returns the same :-)