Regression for x86 atomic fetch or/and no longer generating bts/btr
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Attempting to do a single bit set and check no longer produces `lock bts` on x86
```
std::atomic flag;
bool return_check_bit_1()
{
return (flag.fetch_or(1) & 1) == 1;
}
```
Clang 22.0.1 ( https://godbolt.org/z/dqbz4sGTr )
```
return_check_bit_1():
lock bts dword ptr [rip + flag], 0
setb al
ret
```
Clang trunk 0c101370f58aa7e3d2a6f199bffc5b585cdeab69 ( https://godbolt.org/z/9fffjbfKn )
```
return_check_bit_1():
mov eax, dword ptr [rip + flag]
.LBB1_1:
mov ecx, eax
or ecx, 1
lock cmpxchg dword ptr [rip + flag], ecx
jne .LBB1_1
and al, 1
ret
```
The same issue happens with attempting to unset a bit and check it where it doesn't do the `btr`
Contributor guide
Assessment
This issue has not been assessed yet.