https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90285
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-05-02
Component|c++ |tree-optimization
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Your example boils down to the C testcase
struct S { char arr[1024]; };
struct S *foo (struct S *s)
{
struct S temp;
__builtin_memcpy (&temp, s, sizeof (struct S));
__builtin_memcpy (s, &temp, sizeof (struct S));
return s;
}
which shows that indeed GCC doesn't have a pass doing "copy propagation"
of aggregates.
One might argue that if you write stupid source it might be possible you
get back stupid assembly ;)
But yes, this is a long-standing issue usually popping up when we do not
copy back to s but return temp by value.