missed optimization: combine writes to atomics
Open
missed-optimization
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
We should be able to combine atomic operations to the same address the same way we do with non-atomic operations.
https://godbolt.org/z/K54M5Y7e3
```
void foo(std::atomic& r) {
r.fetch_add(2, std::memory_order_relaxed);
r.fetch_add(4, std::memory_order_relaxed);
}
void foo2(std::atomic& r) {
r.fetch_add(6, std::memory_order_relaxed);
}
void bar(int& r) {
r += 2;
r += 4;
}
void bar2(int& r) {
r += 6;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.