From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 10AA53858437; Tue, 25 Jan 2022 00:04:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10AA53858437 From: "thiago at kde dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103069] cmpxchg isn't optimized Date: Tue, 25 Jan 2022 00:04:17 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thiago at kde dot 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: 12.0 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: Tue, 25 Jan 2022 00:04:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103069 --- Comment #10 from Thiago Macieira --- (In reply to H.J. Lu from comment #9) > nptl/nptl_setxid.c in glibc has >=20 > do=20=20 > {=20=20=20 > flags =3D THREAD_GETMEM (self, cancelhandling); > newval =3D THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, > flags & ~SETXID_BITMASK, flags); > }=20=20=20 > while (flags !=3D newval); >=20 > GCC 12 generates: >=20 > 899f0: 64 8b 14 25 08 03 00 mov %fs:0x308,%edx > 899f8: 89 d6 mov %edx,%esi > 899fa: 89 d0 mov %edx,%eax > 899fc: 83 e6 bf and $0xffffffbf,%esi > 899ff: f0 0f b1 31 lock cmpxchg %esi,(%rcx)=20=20=20=20=20=20= =20 > 89a03: 75 eb jne 899f0 <__GI___nptl_setxid_sighand > ler+0x90> This one is a single bit. This one should be replaced with a LOCK BTC and no loop.=