public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/109930] New: transform atomic exchange to unconditional store when old value is unused?
@ 2023-05-22 10:49 Simon.Richter at hogyros dot de
  2023-05-22 12:38 ` [Bug rtl-optimization/109930] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Simon.Richter at hogyros dot de @ 2023-05-22 10:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109930

            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<uint32_t> x;

    /* ... */

    auto old_value = x.exchange(5);
    assert(old_value == 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-01  1:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 10:49 [Bug rtl-optimization/109930] New: transform atomic exchange to unconditional store when old value is unused? Simon.Richter at hogyros dot de
2023-05-22 12:38 ` [Bug rtl-optimization/109930] " rguenth at gcc dot gnu.org
2023-05-22 15:31 ` pinskia at gcc dot gnu.org
2023-05-22 17:55 ` Simon.Richter at hogyros dot de
2023-05-31 17:29 ` wilco at gcc dot gnu.org
2023-06-01  1:40 ` Simon.Richter at hogyros dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).