public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "andi-gcc at firstfloor dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/55966] __atomic_fetch_* generate wrong code for HLE Date: Mon, 14 Jan 2013 19:06:00 -0000 [thread overview] Message-ID: <bug-55966-4-p9WpJOVfW2@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55966-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55966 --- Comment #1 from Andi Kleen <andi-gcc at firstfloor dot org> 2013-01-14 19:06:02 UTC --- Here's a test case. This requires the libstdc++ HLE patch from http://gcc.gnu.org/ml/gcc-patches/2013-01/msg00673.html g++ -std=gnu++0x #include <atomic> #define ACQ memory_order_acquire | __memory_order_hle_acquire #define REL memory_order_release | __memory_order_hle_release int main() { using namespace std; atomic_ulong au = ATOMIC_VAR_INIT(0); if (!au.fetch_and(1, ACQ)) au.fetch_and(-1, REL); unsigned lock = 0; __atomic_fetch_and(&lock, 1, __ATOMIC_HLE_ACQUIRE|__ATOMIC_ACQUIRE); return 0; } The first fetch_and generates incorrectly: .L2: movq %rax, %rcx movq %rax, %rdx andl $1, %ecx lock; cmpxchgq %rcx, -24(%rsp) jne .L2 The second generates correctly: lock; .byte 0xf3 andq $-1, -24(%rsp) The __atomic_fetch_and generates correctly: lock; .byte 0xf2 andl $1, -28(%rsp) The first fetch_and should generate the same code sequence.
next prev parent reply other threads:[~2013-01-14 19:06 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-01-14 6:11 [Bug target/55966] New: " andi-gcc at firstfloor dot org 2013-01-14 19:06 ` andi-gcc at firstfloor dot org [this message] 2013-01-14 19:52 ` [Bug target/55966] " andi-gcc at firstfloor dot org 2013-01-14 20:15 ` andi-gcc at firstfloor dot org 2013-01-14 21:22 ` ubizjak at gmail dot com 2013-01-14 21:25 ` ubizjak at gmail dot com 2013-01-14 22:05 ` andi-gcc at firstfloor dot org 2013-01-14 22:23 ` amacleod at redhat dot com 2013-01-14 22:32 ` andi-gcc at firstfloor dot org 2013-01-14 22:34 ` andi-gcc at firstfloor dot org 2024-04-09 2:58 ` 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-55966-4-p9WpJOVfW2@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: linkBe 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).