Reduced from gcc.c-torture/execute/builtins/string-asm-2* typedef __SIZE_TYPE__ size_t; extern void abort (void); extern void bcopy (const void *, void *, size_t); char y[64] = "foX"; void * memcpy (void *d, const void *s, size_t n) { char *dst = (char *) d; const char *src = (const char *) s; while (n--) *dst++ = *src++; return (char *) d; } int main (void) { bcopy (y + 1, y + 2, 3); if (y[3] != 'X') abort (); return 0; } With -O0, bcopy stays as is in the final assembly output. With -O1 and above, bcopy is somehow transformed into memcpy. This problem seems to occur at expand-time. On mainline, this problem does not exist.
Note that on this testcase, bcopy must stay as is because source and destination of bcopy overlap.
This is an almost exact (very close in fact references the same test case even) dup of bug 14197. *** This bug has been marked as a duplicate of 14197 ***