[llvm-dev] RFC: Legalize input operand to ATOMIC_CMP_SWAP* by zero-extending
Nemanja Ivanovic via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 5 16:02:33 PST 2018
I've already posted a patch (https://reviews.llvm.org/D41791) to do this,
but here's a bit of a background.
When the operands of an ISD::ATOMIC_CMP_SWAP{_WITH_SUCCESS} are legalized
by promoting to a larger type, they're extended without specifying whether
it's a sign or zero extension. However, an analogous node (SETCC) is
legalized by zero-extending when the comparison code is for an equality
comparison.
The current legalization scheme leads to a bug in the PPC back end when the
input is a negative constant. Namely, the unspecified extension causes the
constant to be materialized with a sign-extending instruction. However, the
atomic load instruction is a zero-extending instruction. Then the
comparison is done on a wider register, leading to a bug. Of course, this
can be fixed in the PPC codegen, but I think it makes more sense to change
how this is legalized since the underlying comparison is indeed an equality
comparison.
Please let me know what you think. Also, if this is a direction we want to
go in, I would appreciate it if people can review the changed test cases.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180106/a61b9914/attachment.html>
More information about the llvm-dev
mailing list