public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dvyukov at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/63273] atomic operations lead to inefficient code
Date: Tue, 16 Sep 2014 17:09:00 -0000	[thread overview]
Message-ID: <bug-63273-4-N0DwxnMTMz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-63273-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Dmitry Vyukov <dvyukov at google dot com> ---
> Which is because to me it's not exactly clear as for what other operations an
atomic load/store is a barrier for.

That's trivial to answer -- memory_order_relaxed is barrier for nothing.

> But eventually that's by design to make locking primitives work
(where we may not move any loads/stores into/out of the protected region).

That's a very bad design for a production compiler. Locking primitives will
necessary include memory_order_acquire/release atomic, and they will prevent
unwanted code movement. Relaxed atomic must not prevent any code movement and
also don't clobber anything. Similarly, memory_order_release should generally
not prevent hoisting of loads above it.

For the record, this is just fixed in clang compiler (did not test yet,
though):
http://llvm.org/bugs/show_bug.cgi?id=17281


  parent reply	other threads:[~2014-09-16 17:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16  1:23 [Bug middle-end/63273] New: " dvyukov at google dot com
2014-09-16  8:59 ` [Bug middle-end/63273] " rguenth at gcc dot gnu.org
2014-09-16 17:09 ` dvyukov at google dot com [this message]
2014-09-16 17:59 ` amacleod at redhat dot com
2014-09-16 18:12 ` dvyukov at google dot com
2014-09-16 19:22 ` amacleod at redhat dot com
2014-09-16 19:57 ` dvyukov at google dot com

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-63273-4-N0DwxnMTMz@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).