From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C747C385842D; Mon, 22 May 2023 10:49:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C747C385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684752552; bh=6J1DMoh86lORv5/mQNjlRbYf72a+qfeBXlQS800x5vQ=; h=From:To:Subject:Date:From; b=VSYG4BtBOCZudnYXixCuOtQ2Vv5/ntWlFnp2B1riIWKTklNrWr3T1CZTZ3DGkw20L QQOjtypS0+4S5fVKBvwR2PsEwHUB+zDIGlH318dRW2Xz8CaYSd3Hkg/NRWb8LHLBnH XLXSFwCqfnv75VbGYFZLNZ/uVx8X/jh4wNi8ElI8= From: "Simon.Richter at hogyros dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/109930] New: transform atomic exchange to unconditional store when old value is unused? Date: Mon, 22 May 2023 10:49:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Simon.Richter at hogyros dot de 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=3D109930 Bug ID: 109930 Summary: transform atomic exchange to unconditional store when old value is unused? Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: Simon.Richter at hogyros dot de Target Milestone: --- I'm not sure if that is a valid substitution, but... I have a state machine that has a few transitions where I already know the = old state, so I can simply do an unconditional store, but I'd also like to have= an assertion on the old state in my debug version: std::atomic x; /* ... */ auto old_value =3D x.exchange(5); assert(old_value =3D=3D 3); with NDEBUG set, the assert is omitted, and no one is interested in the old value, so the load-with-reserve can be omitted and the store-conditional replaced with a regular store, and this should still be semantically equivalent.=