[Bug target/86693] inefficient atomic_fetch_xor

crazylht at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 27 02:18:16 GMT 2021


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

--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
Change testcase a little bit, gcc now can generate lock btc


void func1();

void func(unsigned long *counter)
{
        if (__atomic_fetch_xor(counter, 1, __ATOMIC_ACQ_REL) & 1) {
                func1();
        }
}


func(unsigned long*):
        lock btc        QWORD PTR [rdi], 0
        jc      .L4
        ret
.L4:
        jmp     func1()


More information about the Gcc-bugs mailing list