[Bug target/49244] __sync or __atomic builtins will not emit 'lock bts/btr/btc'
dhowells at redhat dot com
gcc-bugzilla@gcc.gnu.org
Tue May 17 15:51:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49244
--- Comment #20 from dhowells at redhat dot com <dhowells at redhat dot com> ---
Here's a further underoptimisation with -Os:
bool foo_test_and_change_bit(unsigned long *p)
{
return test_and_change_bit(83, p);
}
is compiled to:
0000000000000015 <foo_test_and_change_bit>:
15: f0 48 0f ba 7f 08 13 lock btcq $0x13,0x8(%rdi)
1c: 0f 92 c0 setb %al
1f: c3 retq
However, the bit number on BTCQ is an imm8, so the displacement on the memory
operand is unnecessary if the bit number will fit inside the imm8.
More information about the Gcc-bugs
mailing list