[Bug target/86693] inefficient atomic_fetch_xor
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Dec 27 03:03:07 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86693
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Hongtao.liu from comment #4)
> 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()
We should rewrite the original test to the canonical form, similar to r12-5102.
Hongtao, can you do that?
More information about the Gcc-bugs
mailing list