http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50123
Bug #: 50123 Summary: cmpxchg generated for atomic and with zero/or with -1 Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: bonz...@gnu.org int x; int f() { return __sync_fetch_and_and(&x, 0); } int g() { return __sync_fetch_and_or(&x, -1); } f and g can be optimized to atomic xchg on x86.