From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9AAB23858C52; Fri, 3 Feb 2023 15:42:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AAB23858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675438950; bh=cAfuiHUAJGVG/aMBcQoWJJwWNiuJe01ZjES/RjHob0c=; h=From:To:Subject:Date:From; b=tIJcG923FjgaMd8kVSwfrSkvU0236t4iUE13738D4rBX3+ERPSWK9KR/BWcQmaoPX XLGY7sm63+FbU2vpgKkI9u/ZXCk3igqGbWoz5CWxbWEyyqL0YvHYSp5eRgT7QL6UJw HKnsFgJdrZOhE7b4YcTjnkavAnZAkri7lPWRo534= From: "s_gccbugzilla at nedprod dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108659] New: Suboptimal 128 bit atomics codegen on AArch64 and x64 Date: Fri, 03 Feb 2023 15:42:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: s_gccbugzilla at nedprod dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108659 Bug ID: 108659 Summary: Suboptimal 128 bit atomics codegen on AArch64 and x64 Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: s_gccbugzilla at nedprod dot com Target Milestone: --- Related: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80878 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94649 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104688 I got bitten by this again, latest GCC still does not emit single instructi= on 128 bit atomics, even when the -march is easily new enough. Here is a godbo= lt comparing latest MSVC, latest GCC and latest clang for the skylake-avx512 architecture, which unquestionably supports cmpxchg16b. Only clang emits the single instruction atomic: https://godbolt.org/z/EnbeeW4az I'm gathering from the issue comments and from the comments at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104688 that you're going to = wait for AMD to guarantee atomicity of SSE instructions before changing the code= gen here, which makes sense. However I also wanted to raise potentially subopti= mal 128 bit atomic codegen by GCC for AArch64 as compared to clang: https://godbolt.org/z/oKv4o81nv GCC emits `dmb` to force a global memory fence, whereas clang does not. I think clang is in the right here, the seq_cst atomic semantics are not supposed to globally memory fence.=