public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/105162] New: [AArch64] outline-atomics drops dmb ish barrier on __sync builtins
@ 2022-04-05 15:29 spop at gcc dot gnu.org
  2022-04-05 16:55 ` [Bug target/105162] " spop at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: spop at gcc dot gnu.org @ 2022-04-05 15:29 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2022-10-27  2:30 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 15:29 [Bug target/105162] New: [AArch64] outline-atomics drops dmb ish barrier on __sync builtins spop at gcc dot gnu.org
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

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).