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

Patrick O'Neill <patrick at rivosinc dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |patrick at rivosinc dot com

--- Comment #11 from Patrick O'Neill <patrick at rivosinc dot com> ---
The Char example from this issue is resolved on trunk since we added inline
subword atomics.
https://inbox.sourceware.org/gcc-patches/20230418214124.2446642-1-patr...@rivosinc.com/

Char example: https://godbolt.org/z/h94PT7hfo

char atomic(char *i) {
  char j = __atomic_add_fetch(i, 1, __ATOMIC_SEQ_CST);
  char k;
  __atomic_load(i, &k, __ATOMIC_SEQ_CST);
  return j+k;
} 

options: -O3 -march=rv64iad

atomic(char*):
        andi    a4,a0,3
        slliw   a4,a4,3
        li      a3,255
        sllw    a3,a3,a4
        li      a1,1
        andi    a2,a0,-4
        not     a6,a3
        sllw    a1,a1,a4
        1:
        lr.w.aqrl       a5, 0(a2)
        add     a7, a5, a1
        and     a7, a7, a3
        and     t1, a5, a6
        or      t1, t1, a7
        sc.w.rl a7, t1, 0(a2)
        bnez    a7, 1b
        sraw    a5,a5,a4
        addiw   a5,a5,1
        andi    a5,a5,0xff
        fence   rw,rw
        lbu     a0,0(a0)
        fence   rw,rw
        add     a0,a0,a5
        andi    a0,a0,0xff
        ret

The initial example's behavior is still present.

Reply via email to