[llvm-dev] Question on ATOMIC_CMP_SWAP results being sign or zero extended

Simon Dardis via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 15 09:39:11 PDT 2016


Hello,

I'm trying to fix a wrong code bug for MIPS regarding ATOMIC_CMP_SWAP_WITH_SUCCESS and partial word atomics.

Nodes of that type get legalized into ATOMIC_CMP_SWP with a SETCC of the result and the comparison value. For MIPS this  introduces a bug as partial word atomics have their results sign-extended and can be compared to unsigned value.

Are the results of ATOMIC_CMP_SWAP_WITH_SUCCESS and ATOMIC_CMP_SWAP defined or expected to be zero-extended or sign-extended? Or is it just "do something sensible for your target"?

Looking at the X86, PowerPC and AArch64 backends seems to show that they don't sign-extend the results of ATOMIC_CMP_SWAP*.

Thanks,
Simon


More information about the llvm-dev mailing list