https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93177
--- Comment #11 from Matt Emmerton <memmerto at ca dot ibm.com> --- > > > > The implementation of stwcx() and stdcx() need revision on PPC. > > > > As I understand it, there is no need the mfocrf instruction nor the > > > > mask-and-shift on result. > > > > > > How else would you output the CR0.EQ bit? > > > > There is no need to copy CR0 to a GPR - branch instructions such as BNE can > > operate on CR0 directly. > > You cannot write anything that maps to a CR field directly. No need to access it directly - just use a BNE instruction (to branch for retry/success) which operates implicitly on CR0.EQ. There are plenty of material out there that implements atomic operations on POWER like this: loop: lwarx // do something stwcx bne loop: gcc does an unnecessary mfocrf + cmp to achieve the same result. Is there an assumption in gcc that the "result" of any intrinsic is reported in a GPR, which disallows this implicit use of CR0?