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

--- Comment #3 from Jeffrey A. Law <law at redhat dot com> ---
It's not an off by 1 error, but a conscious decision to not pass odd addresses
into the mem* routines, which are typically doing to emit crappy code for badly
aligned data.

We correctly see that 7 bytes of data are live and that we only need a single
byte write for the first memset.  One could certainly argue that in the case
were a single byte (or even perhaps up to 3 bytes) are all that's left that we
should do a full trim because the first mem* routine should end up open-coded.

If I hack something like that together we end up with:

  MEM[(void *)&a + 7B] = 0;
  __builtin_memset (&a, 0, 7);
  f (&a);
  a ={v} {CLOBBER};
  return;


THe fact that the two memset calls use the same value is a testsuite quirk that
would allow this to be further optimized.  I'm skeptical that happens often
enough in practice to be worth optimizing.   If someone were to want to
optimize that better, I'd think the strlen pass is probably the right place.

Reply via email to