The C++ and C semantics of the compare_and_swap operations actually require us to return a boolean "success" value. In LLVM terms this means a second comparison of the output of "cmpxchg" against the input desired value.
However, x86's "cmpxchg" instruction sets all flags for the comparison formed, so we can skip any secondary comparison. (N.b. this isn't true for cmpxchg8b/16b, which only set ZF -- I'm hoping to deal with them in a separate patch later).
A bit of refactoring was needed, but there should be no actual changes to the LowerCMP_SWAP function.
OK to commit?
Cheers.
Tim.