https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102382

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> There's a missed optimization w/o vectorization, strlenopt seems to remove
> the p[0] = '\0' store but not the stores to elements 1 to 3.

strlen pass doesn't have any infrastructure to know that more than one
consecutive byte is known to be zero.  It just notes the string length (certain
number of bytes from some pointer known to be non-0 and then one 0) or
non-terminated (certain number of bytes from some pointer known to be non-0).
So, for calloc it can only record that it returns zero terminated string with
length 0, not how many following bytes are also 0.

So, if we want to optimize these special cases of calloc + stores of zero
afterwards, that is a task for some other pass (doesn't DSE do that?).

Reply via email to