From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4649D383800D; Thu, 6 May 2021 19:32:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4649D383800D From: "pinskia at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 7.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2021 19:32:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80878 --- Comment #31 from Andrew Pinski --- (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=3Dsandybridge: >=20 > - On GCC 6.4 and earlier, this emits lock cmpxchg16b, as you would expect. >=20 > - From GCC 7 up to trunk (12?), this emits __atomic_compare_exchange_16. >=20 > - On clang, this emits lock cmpxchg16b, as you would expect. >=20 > This is clearly a regression. GCCs before 7 did the right thing. GCCs fro= m 7 > onwards do not. clangs with libstdc++ do do the right thing. >=20 > 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. >=20 > 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 x6= 4. Again the problem is stuff like: static const _Atomic __int128_t t =3D 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 t= he LSE (from ARMv8.1-a) is useful.=