public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/80878] -mcx16 (enable 128 bit CAS) on x86_64 seems not to work on 7.1.0
Date: Thu, 06 May 2021 19:32:51 +0000	[thread overview]
Message-ID: <bug-80878-4-IZqBtobb9H@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-80878-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #31 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Niall Douglas from comment #30)
> I got bit by this GCC regression today at work. Consider
> https://godbolt.org/z/M9fd7nhdh where std::atomic<__int128> is compare
> exchanged with -march=sandybridge:
> 
> - On GCC 6.4 and earlier, this emits lock cmpxchg16b, as you would expect.
> 
> - From GCC 7 up to trunk (12?), this emits __atomic_compare_exchange_16.
> 
> - On clang, this emits lock cmpxchg16b, as you would expect.
> 
> This is clearly a regression. GCCs before 7 did the right thing. GCCs from 7
> onwards do not. clangs with libstdc++ do do the right thing.
> 
> This isn't just an x64 thing, either. Consider
> https://godbolt.org/z/x6d5GE4o6 where GCC on ARM64 emits
> __atomic_compare_exchange_16, whereas clang on ARM64 emits ldaxp/stlxp, as
> you would expect.
> 
> Please mark this bug as a regression affecting all versions of GCC from 7 to
> trunk, and affecting all 128 bit atomic capable architectures not just x64.

Again the problem is stuff like:
static const _Atomic __int128_t t = 2000;

__int128_t g(void)
{
  return t;
}

DOES NOT WORK if you use CAS (or ldaxp/stlxp).

So clang is broken really ....

Also GCC for ARM64 emits calls for all compare and exchange because using the
LSE (from ARMv8.1-a) is useful.

  parent reply	other threads:[~2021-05-06 19:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-80878-4@http.gcc.gnu.org/bugzilla/>
2020-04-18 17:14 ` avi@cloudius-systems.com
2020-04-18 17:23 ` fw at gcc dot gnu.org
2020-04-18 17:31 ` avi@cloudius-systems.com
2020-04-18 17:40 ` fw at gcc dot gnu.org
2020-04-18 18:13 ` avi@cloudius-systems.com
2020-04-18 18:18 ` avi@cloudius-systems.com
2020-04-18 18:41 ` fw at gcc dot gnu.org
2021-03-14  3:21 ` wuyongwei at gmail dot com
2021-03-14  3:46 ` wuyongwei at gmail dot com
2021-03-16 16:02 ` wuyongwei at gmail dot com
2021-05-06 17:50 ` s_gccbugzilla at nedprod dot com
2021-05-06 19:32 ` pinskia at gcc dot gnu.org [this message]
2021-05-06 20:53 ` liblfds_gccbz at winterflaw dot net
2021-05-07 12:27 ` s_gccbugzilla at nedprod dot com
2021-05-07 14:07 ` redi at gcc dot gnu.org
2021-05-07 14:44 ` s_gccbugzilla at nedprod dot com
2022-11-03  9:55 ` lh_mouse at 126 dot com
2022-11-03 10:04 ` jakub at gcc dot gnu.org
2022-11-03 10:32 ` fw at gcc dot gnu.org
2022-11-03 11:16 ` admin_public at liblfds dot org
2023-11-16  1:33 ` lh_mouse at 126 dot com
2023-12-10  9:54 ` lh_mouse at 126 dot com
2023-12-10 10:32 ` admin_public at liblfds dot 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-80878-4-IZqBtobb9H@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).