public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111121] New: AArch64: MOPS memmove operand corruption
@ 2023-08-23 14:25 wilco at gcc dot gnu.org
  2023-08-23 14:26 ` [Bug target/111121] " wilco at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: wilco at gcc dot gnu.org @ 2023-08-23 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
@ 2023-08-23 14:26 ` wilco at gcc dot gnu.org
  2023-08-23 14:26 ` wilco at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: wilco at gcc dot gnu.org @ 2023-08-23 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Wilco <wilco at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-23
           Assignee|unassigned at gcc dot gnu.org      |wilco at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |12.0, 13.0
             Status|UNCONFIRMED                 |ASSIGNED

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
  2023-08-23 14:26 ` [Bug target/111121] " wilco at gcc dot gnu.org
@ 2023-08-23 14:26 ` wilco at gcc dot gnu.org
  2023-08-23 17:34 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: wilco at gcc dot gnu.org @ 2023-08-23 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Wilco <wilco at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0
             Target|                            |AArch64

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
  2023-08-23 14:26 ` [Bug target/111121] " wilco at gcc dot gnu.org
  2023-08-23 14:26 ` wilco at gcc dot gnu.org
@ 2023-08-23 17:34 ` pinskia at gcc dot gnu.org
  2023-08-24  6:44 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-23 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=103100

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Wilco from comment #0)
> -mstrict-align is ignored with small constant-sized memcpy if MOPS is
> enabled:

-mstrict-align is also broken for memset, see PR 103100.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-08-23 17:34 ` pinskia at gcc dot gnu.org
@ 2023-08-24  6:44 ` rguenth at gcc dot gnu.org
  2023-09-28 15:34 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-24  6:44 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |12.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-08-24  6:44 ` rguenth at gcc dot gnu.org
@ 2023-09-28 15:34 ` cvs-commit at gcc dot gnu.org
  2023-09-29 12:14 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-28 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Wilco Dijkstra <wilco@gcc.gnu.org>:

https://gcc.gnu.org/g:d8b56c95782aeeee79ec40932ca88d00fd9f2ee2

commit r14-4311-gd8b56c95782aeeee79ec40932ca88d00fd9f2ee2
Author: Wilco Dijkstra <wilco.dijkstra@arm.com>
Date:   Tue Sep 26 16:42:45 2023 +0100

    AArch64: Fix memmove operand corruption [PR111121]

    A MOPS memmove may corrupt registers since there is no copy of the input
    operands to temporary registers.  Fix this by calling
    aarch64_expand_cpymem_mops.

    Reviewed-by: Richard Sandiford <richard.sandiford@arm.com>

    gcc/ChangeLog/
            PR target/111121
            * config/aarch64/aarch64.md (aarch64_movmemdi): Add new expander.
            (movmemdi): Call aarch64_expand_cpymem_mops for correct expansion.
            * config/aarch64/aarch64.cc (aarch64_expand_cpymem_mops): Add
support
            for memmove.
            * config/aarch64/aarch64-protos.h (aarch64_expand_cpymem_mops): Add
new
            function.

    gcc/testsuite/ChangeLog/
            PR target/111121
            * gcc.target/aarch64/mops_4.c: Add memmove testcases.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-09-28 15:34 ` cvs-commit at gcc dot gnu.org
@ 2023-09-29 12:14 ` cvs-commit at gcc dot gnu.org
  2023-09-29 12:15 ` cvs-commit at gcc dot gnu.org
  2023-09-29 12:25 ` wilco at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-29 12:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Wilco Dijkstra
<wilco@gcc.gnu.org>:

https://gcc.gnu.org/g:c534a9b198caa3807bcc592a3c5bac3f971417f7

commit r13-7921-gc534a9b198caa3807bcc592a3c5bac3f971417f7
Author: Wilco Dijkstra <wilco.dijkstra@arm.com>
Date:   Tue Sep 26 16:42:45 2023 +0100

    AArch64: Fix memmove operand corruption [PR111121]

    A MOPS memmove may corrupt registers since there is no copy of the input
    operands to temporary registers.  Fix this by calling
    aarch64_expand_cpymem_mops.

    Reviewed-by: Richard Sandiford <richard.sandiford@arm.com>

    gcc/ChangeLog/
            PR target/111121
            * config/aarch64/aarch64.md (aarch64_movmemdi): Add new expander.
            (movmemdi): Call aarch64_expand_cpymem_mops for correct expansion.
            * config/aarch64/aarch64.cc (aarch64_expand_cpymem_mops): Add
support
            for memmove.
            * config/aarch64/aarch64-protos.h (aarch64_expand_cpymem_mops): Add
new
            function.

    gcc/testsuite/ChangeLog/
            PR target/111121
            * gcc.target/aarch64/mops_4.c: Add memmove testcases.

    (cherry picked from commit d8b56c95782aeeee79ec40932ca88d00fd9f2ee2)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-09-29 12:14 ` cvs-commit at gcc dot gnu.org
@ 2023-09-29 12:15 ` cvs-commit at gcc dot gnu.org
  2023-09-29 12:25 ` wilco at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-29 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Wilco Dijkstra
<wilco@gcc.gnu.org>:

https://gcc.gnu.org/g:bc1e385488001b0bd1a9b9c55b09ce987c31d353

commit r12-9898-gbc1e385488001b0bd1a9b9c55b09ce987c31d353
Author: Wilco Dijkstra <wilco.dijkstra@arm.com>
Date:   Tue Sep 26 16:42:45 2023 +0100

    AArch64: Fix memmove operand corruption [PR111121]

    A MOPS memmove may corrupt registers since there is no copy of the input
    operands to temporary registers.  Fix this by calling
    aarch64_expand_cpymem_mops.

    Reviewed-by: Richard Sandiford <richard.sandiford@arm.com>

    gcc/ChangeLog/
            PR target/111121
            * config/aarch64/aarch64.md (aarch64_movmemdi): Add new expander.
            (movmemdi): Call aarch64_expand_cpymem_mops for correct expansion.
            * config/aarch64/aarch64.cc (aarch64_expand_cpymem_mops): Add
support
            for memmove.
            * config/aarch64/aarch64-protos.h (aarch64_expand_cpymem_mops): Add
new
            function.

    gcc/testsuite/ChangeLog/
            PR target/111121
            * gcc.target/aarch64/mops_4.c: Add memmove testcases.

    (cherry picked from commit d8b56c95782aeeee79ec40932ca88d00fd9f2ee2)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/111121] AArch64: MOPS memmove operand corruption
  2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-09-29 12:15 ` cvs-commit at gcc dot gnu.org
@ 2023-09-29 12:25 ` wilco at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: wilco at gcc dot gnu.org @ 2023-09-29 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

Wilco <wilco at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Wilco <wilco at gcc dot gnu.org> ---
Fixed on trunk, backported to GCC13 and GCC12.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-29 12:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-23 14:25 [Bug target/111121] New: AArch64: MOPS memmove operand corruption wilco at gcc dot gnu.org
2023-08-23 14:26 ` [Bug target/111121] " wilco at gcc dot gnu.org
2023-08-23 14:26 ` wilco at gcc dot gnu.org
2023-08-23 17:34 ` pinskia at gcc dot gnu.org
2023-08-24  6:44 ` rguenth at gcc dot gnu.org
2023-09-28 15:34 ` cvs-commit at gcc dot gnu.org
2023-09-29 12:14 ` cvs-commit at gcc dot gnu.org
2023-09-29 12:15 ` cvs-commit at gcc dot gnu.org
2023-09-29 12:25 ` wilco at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).