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

            Bug ID: 98658
           Summary: Loop idiom recognization for memcpy/memmove
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.bolvansky at gmail dot com
  Target Milestone: ---

void copy(int *__restrict__ d, int * s, __SIZE_TYPE__ sz) {
    __SIZE_TYPE__ i;
    for (i = 0; i < sz; i++) {
        *d++ = *s++;
    }
}

gcc emits call to memcpy.



void copy(int * d, int * s, __SIZE_TYPE__ sz) {
    __SIZE_TYPE__ i;
    for (i = 0; i < sz; i++) {
        *d++ = *s++;
    }
}


gcc could emit memmove, but currently does not:
https://godbolt.org/z/5n1rnh

Reply via email to