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

            Bug ID: 111121
           Summary: AArch64: MOPS memmove operand corruption
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wilco at gcc dot gnu.org
  Target Milestone: ---

Since GCC 12.0 the following example corrupts x0 when built with -O2
-march=armv8.6-a+mops:

int *f (int *p, int *q, long n) { memmove (p, q, n); return p; }

f:
        cpyp    [x0]!, [x1]!, x2!
        cpym    [x0]!, [x1]!, x2!
        cpye    [x0]!, [x1]!, x2!
        ret

The expansion for memcpy works differently and inserts a copy to a temporary.

-mstrict-align is ignored with small constant-sized memcpy if MOPS is enabled:

void g(int *p, int *q) { memcpy (p, q, 32); }

g:
        ldp     q0, q1, [x1]
        stp     q0, q1, [x0]
        ret

Reply via email to