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

            Bug ID: 90263
           Summary: Calls to mempcpy should use memcpy
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wilco at gcc dot gnu.org
  Target Milestone: ---

While GCC now inlines fixed-size mempcpy like memcpy, GCC still emits calls to
mempcpy rather than converting to memcpy. Since most libraries, including
GLIBC, do not have optimized mempcpy for most targets, calling mempcpy is less
efficient than calling memcpy and emitting an extra addition to compute the
result.

int *mempcopy1 (int *p, int *q)
{
  return  __builtin_mempcpy (p, q, 16);
}

int *mempcopy2 (int *p, int *q, long n)
{
  return __builtin_mempcpy (p, q, n);
}

mempcopy1:
        ldp     x2, x3, [x1]
        stp     x2, x3, [x0], 16
        ret

mempcopy2:
        b       mempcpy

Reply via email to