From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B188138582AC; Wed, 18 Jan 2023 22:30:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B188138582AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674081018; bh=ECqmSnVMyJCtaryRUwifoosJXctYfXghYtFo6/x3cwM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qT/d1SkGLmpZwefVIIyG/owEsBJuJ1OVlbXDRAENui6fVKZFTUyT6LJoC0dULTGrP dTyvKwCGIdggzTD1Xf54Bwyx+D3Jx995wRceBPIE9eO6UwxUzyqCMYfrUndjDRDb9I GYEZW470l2wWMav5XpXTNlg0Y0fSg4vgtDSbolxQ= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102566] [i386] GCC should emit LOCK BTS for simple bit-test-and-set operations with std::atomic Date: Wed, 18 Jan 2023 22:30:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: hjl.tools at gmail dot com 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102566 --- Comment #37 from H.J. Lu --- It is if ((__atomic_fetch_xor_4 ((volatile void *) a, (unsigned int) (1 << bit), = 0)=20 & (unsigned int) (1 << bit)) !=3D 0) vs if ((__atomic_fetch_xor_4 ((volatile void *) a, 1 << bit, 0) >> bit & 1) != =3D 0) Why does GCC generate the second one?=