https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111657
--- Comment #9 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Jakub Jelinek from comment #8) > I'd say it is a user error to invoke memcpy/memset etc. with pointers to > non-default address spaces, and for aggregate copies the middle-end should > ensure that the copying is not done using library calls; is that the case > and the problem was just that optab expansion was allowed for the structure > copies and the backend decided to use libcall in that case? Yes, the stringop selection mechanism chose libcall strategy. However, the call to memcpy is unavailable for non-default address space, so the middle-end expanded the call into most trivial byte-copy loop. The patch just teaches stringop selection to use optimized copy loop as a last resort with non-default address spaces instead.