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

--- Comment #11 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to rguent...@suse.de from comment #10)
> 
> What makes the parameter type special?  Would
> 
> void test (const int *a, int *b)
> {
>   std::memcpy ((char *)b, (char *)a, t);
> }
> 
> be invalid to optimize to an aligned copy in your eyes?

I think it's perfectly valid to optimize this case.  It could as well be
something like:

void test (const int *a, int *b)
{
  a[100] = 1;
  b[200] = 2;

  std::memcpy ((char *)b, (char *)a, t);
}

where a[100] and b[200] both would result in 32 bit accesses, not 4x1 byte or
something, because the base pointer is assumed to be int aligned.  Why should
memcpy be any different?

Reply via email to