There are a few issues with the code we generate for atomic operations and the way we generate it:
- Hard coded CR0 for compares
- Order of operands for compares not conducive to emitting compare-immediate or for CSE of compares
- Missing MachineMemOperand for st[bhwd]cx intrinsics
- A missing intrinsic property for the same
- Unnecessary blocks with store conditional instructions to clear reservation (which ends up hindering performance)
- Move from CR instructions just to compare the result of a store conditional with zero (even though it is a record-form)
This patch aims to resolve all of those issues.
Is it missing a test, kinda like
define signext i1 @foo(i64* %addr, i64 %newval) { entry: %0 = bitcast i64* %addr to i8* br label %while.cond while.cond: ; preds = %while.body, %entry %1 = tail call i32 @llvm.ppc.stdcx(i8* %0, i64 %newval) %ok = icmp eq i32 %1, 0 br i1 %ok, label %end, label %end.0 end: ret i1 0 end.0: ret i1 1 }