From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5D863385840C; Fri, 5 Nov 2021 12:33:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D863385840C From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103066] __sync_val_compare_and_swap/__sync_bool_compare_and_swap aren't optimized Date: Fri, 05 Nov 2021 12:33:22 +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: 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 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: Fri, 05 Nov 2021 12:33:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103066 --- Comment #4 from H.J. Lu --- (In reply to Jakub Jelinek from comment #3) > If by fail you mean that it doesn't update the memory if the memory isn't > equal to expected, sure, but do you mean it can fail spuriously, not upda= te > the memory even if the memory is equal to expected? > Neither __sync_{bool,val}_compare_and_swap nor __atomic_compare_exchange_n > with weak set to false can fail spuriously, __atomic_compare_exchange_n w= ith > weak set to true can. If we generate movl m(%rip), %eax cmpl %edi, %eax jne .L1 movl %edi, %eax lock cmpxchgl %esi, m(%rip) .L1: ret is it a valid implementation of atomic_compare_exchange_strong?=