If I declare an atomic variable, which is only used in a single thread, are compilers able to optimize that out, and replace std::atomic<T> with T in some cases?
I've read some articles about the compiler optimizations of atimics, but they are mostly about reordering and grouping locks and stores, not about eliminating them.
Let's take std:shared_pointer for example. It has an atomic counter, but if only a single thread can access it, it could be replaced with a simple counter, and it would still behave as if it would be an atomic.
Aucun commentaire:
Enregistrer un commentaire