https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67618
--- Comment #12 from Marc Glisse <glisse at gcc dot gnu.org> --- (In reply to Daniel Gutson from comment #11) > > > void caller(void) > > > { > > > void* ptr = function(1); > > > *(char*)ptr = 1; > > > } > > > > Maybe file another bug which does the opposite transformation for the cases > > where memcpy happens after the calloc. There is not enough information to > > know if the value is going to be <=15 most of the time or not so we just > > guess. > > Can't we use this one? In cases where we have malloc, memset(0,,...) and then another write that overwrites the whole content, DSE (or some other pass) will already remove the memset(0) long before the transformation into calloc, which then will not happen. If you try to compile your example above, "caller" calls malloc, not calloc.