On Tue, 19 Nov 2024, Maciej W. Rozycki wrote:

> > time I think the RMW sequence on _Atomic variables is a clear
> > bug that you'd need to fix also for -mno-safe-bwa.
> 
>  That's weird indeed, GCC internals manual clearly says:
> 
> "'atomic_storeMODE'
>      This pattern implements an atomic store operation with memory model
>      semantics.  Operand 0 is the memory address being stored to.
>      Operand 1 is the value to be written.  Operand 2 is the memory
>      model to be used for the operation.
> 
>      If not present, the '__atomic_store' built-in function will attempt
>      to perform a normal store and surround it with any required memory
>      fences.  If the store would not be atomic, then an
>      '__atomic_exchange' is attempted with the result being ignored."
> 
> and while we do not have `atomic_storeqi' nor `atomic_storehi' operations 
> we do have `atomic_exchangeqi' and `atomic_exchangehi' ones defined in the 
> Alpha backend (for byte and word operations respectively).  So presumably 
> the middle end is not aware for some reason that on non-BWX Alpha normal 
> QI and HI mode stores are not atomic.

 FTR the reason is the middle end universally assumes, in the absence of 
an 'atomic_storeMODE' pattern, that stores are atomic for object sizes of 
up to the target's word size, which does not stand for non-BWX Alpha.  

>  I do hope this obviously obscure but trivial GCC bug was not the *sole* 
> reason to drop non-BWX support from Linux.

 I found no previous bug report, so this is now PR target/117759[1].  An 
obvious bug fix has been posted for review as well[2].

References:

[1] "Alpha: `_Atomic' keyword not respected for !BWX and 8-bit/16-bit stores", 
    <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117759>

[2] "Alpha: Respect `_Atomic' keyword for HI and QI data on !BWX [PR117759]",
    
<https://inbox.sourceware.org/gcc-patches/alpine.deb.2.21.2411222217440.10...@angie.orcam.me.uk/>

  Maciej

Reply via email to