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

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jakub Jelinek from comment #3)
> If by fail you mean that it doesn't update the memory if the memory isn't
> equal to expected, sure, but do you mean it can fail spuriously, not update
> the memory even if the memory is equal to expected?
> Neither __sync_{bool,val}_compare_and_swap nor __atomic_compare_exchange_n
> with weak set to false can fail spuriously, __atomic_compare_exchange_n with
> weak set to true can.

If we generate

        movl m(%rip), %eax
        cmpl  %edi, %eax
        jne  .L1
        movl    %edi, %eax
        lock cmpxchgl   %esi, m(%rip)
.L1:
        ret

is it a valid implementation of atomic_compare_exchange_strong?

Reply via email to