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

--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Atomic loads and stores have to use the same policy for a single object, you
can't have loads using one model and stores another.

Atomic loads have to work even if the object is marked const.

C/C++ permit a non-const object pointer to be cast to a const object pointer. 
That means that any mechanism used for atomic loads has to work with const
objects, in particular with objects that are immutable (would trap if
modification were attempted).

The v8 ARM ARM says that the way to perform a 128-bit atomic read using ldxp is
to read the value and then attempt to store it back using a stxp; if the store
succeeds, then the read was atomic, otherwise it was not and must be retried. 
This model doesn't work if the object was immutable, since the store will
fault.

The consequence of this is that ldxp cannot be used for atomic 128-bit reads. 
And the consequence of that is that stxp cannot be used for 128-bit stores. 
Ergo, the only way to perform 128-bit atomic accesses is by using locks.  So I
think the existing code is correct.

I'll leave this open for the moment for further discussion, but I'm minded to
reject as INVALID.

Reply via email to