public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "avi@cloudius-systems.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94649] New: 16-byte aligned atomic_compare_exchange doesn not generate cmpxcg16b on x86_64
Date: Sat, 18 Apr 2020 18:17:38 +0000	[thread overview]
Message-ID: <bug-94649-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 94649
           Summary: 16-byte aligned atomic_compare_exchange doesn not
                    generate cmpxcg16b on x86_64
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avi@cloudius-systems.com
  Target Milestone: ---

The code

#include <atomic>

struct alignas(16) a {
    long x;
    long y;
};

bool cmpxchg(std::atomic<a>& data, a expected, a newval) {
    return std::atomic_compare_exchange_weak(&data, &expected, newval);
}

compiles with -O3 -mcx16 generates a "lock cmpxchg16b" instruction with clang,
but not with gcc, where it generates a library call to
__atomic_compare_exchange_16. This is a missed optimization.

             reply	other threads:[~2020-04-18 18:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18 18:17 avi@cloudius-systems.com [this message]
2020-04-20  7:03 ` [Bug target/94649] " rguenth at gcc dot gnu.org
2020-04-20 11:37 ` avi@cloudius-systems.com
2021-03-14  3:10 ` wuyongwei at gmail dot com
2021-05-07 14:44 ` s_gccbugzilla at nedprod dot com
2023-02-15 10:56 ` balder at yahooinc dot com
2023-02-15 10:59 ` jakub at gcc dot gnu.org
2023-02-17  7:53 ` balder at yahooinc 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-94649-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).