public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "spop at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/105162] New: [AArch64] outline-atomics drops dmb ish barrier on __sync builtins
Date: Tue, 05 Apr 2022 15:29:19 +0000	[thread overview]
Message-ID: <bug-105162-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105162
           Summary: [AArch64] outline-atomics drops dmb ish barrier on
                    __sync builtins
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spop at gcc dot gnu.org
  Target Milestone: ---

With -mno-outline-atomics gcc produces a `dmb ish` barrier on __sync builtins
as required by the Intel specification 
(see fix for https://gcc.gnu.org/PR65697 
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=f70fb3b635f9618c6d2ee3848ba836914f7951c2
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ab876106eb689947cdd8203f8ecc6e8ac38bf5ba
)

$ cat a.c
int foo(int a)
{
  return __sync_bool_compare_and_swap(&a, 4, 5);
}
$ gcc -O2 a.c -S -o- -mno-outline-atomics 
foo:
        sub     sp, sp, #16
        mov     w1, 5
        str     w0, [sp, 12]
        add     x0, sp, 12
.L4:
        ldxr    w2, [x0]
        cmp     w2, 4
        bne     .L5
        stlxr   w3, w1, [x0]
        cbnz    w3, .L4
.L5:
        dmb     ish
        cset    w0, eq
        add     sp, sp, 16
        ret

With -moutline-atomics gcc does not generate the barrier:

$ gcc -O2 a.c -S -o-  -moutline-atomics 
foo:
        stp     x29, x30, [sp, -32]!
        mov     w1, 5
        mov     x29, sp
        add     x2, sp, 28
        str     w0, [sp, 28]
        mov     w0, 4
        bl      __aarch64_cas4_acq_rel
        cmp     w0, 4
        cset    w0, eq
        ldp     x29, x30, [sp], 32
        ret

Happens on gcc-8, 9, 10, 11, and trunk.

             reply	other threads:[~2022-04-05 15:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 15:29 spop at gcc dot gnu.org [this message]
2022-04-05 16:55 ` [Bug target/105162] " spop at gcc dot gnu.org
2022-04-05 16:56 ` spop at gcc dot gnu.org
2022-04-05 21:18 ` spop at gcc dot gnu.org
2022-04-06 15:03 ` spop at gcc dot gnu.org
2022-04-06 21:55 ` spop at gcc dot gnu.org
2022-04-07  8:47 ` ktkachov at gcc dot gnu.org
2022-04-14 11:22 ` wilco at gcc dot gnu.org
2022-04-18 15:20 ` spop at gcc dot gnu.org
2022-05-13 17:11 ` cvs-commit at gcc dot gnu.org
2022-05-16 13:18 ` cvs-commit at gcc dot gnu.org
2022-05-16 14:40 ` cvs-commit at gcc dot gnu.org
2022-05-16 14:42 ` cvs-commit at gcc dot gnu.org
2022-05-16 14:44 ` cvs-commit at gcc dot gnu.org
2022-05-16 14:59 ` spop at gcc dot gnu.org
2022-10-27  2:28 ` pinskia at gcc dot gnu.org
2022-10-27  2:30 ` [Bug target/105162] [9/10/11/12/13 Regression] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105162-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).