https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70825
ghalliday at hpccsystems dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ghalliday at hpccsystems dot com --- Comment #4 from ghalliday at hpccsystems dot com --- I have also hit this problem on x86 and Power8, and am adding a comment about its significance. Although it seems a minor bug it can have a very significant effect on performance. I have code which uses __sync_bool_compare_and_swap() to implement a lock free linked list (inside a memory manager). Replacing it with __atomic_compare_exchange_n should allow better performance - by avoiding reloading the expected value (and also selecting a less restrictive memory order). However on one example test query, the new code using __atomic_compare_exchange_n is over 40% *slower* on x86. It is also slower on Power8 despite using a lwsync instead of sync in the generated code.