[PATCH] D41856: [PowerPC] Zero-extend the compare operand for ATOMIC_CMP_SWAP
Nemanja Ivanovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 9 02:27:47 PST 2018
nemanjai created this revision.
nemanjai added reviewers: hfinkel, echristo, power-llvm-team.
Herald added a subscriber: kbarton.
This fixes https://bugs.llvm.org/show_bug.cgi?id=35812.
As it turns out, the PPC back end has a long-standing bug where the atomic compare and swap operation on sub-word sizes will do the wrong thing if the old value (and the comparand) is negative. The issue is that the old value we load will be zero-extended and the value we're comparing it to might be sign or zero extended. This is broken both with the old way of loading/masking the value as well as with the new way (using the `lharx/lbarx` that were introduced in ISA 2.07).
This patch simply zero extends the input value if it isn't already guaranteed to be zero extended.
I initially posted a fix for this in legalization, but there was at least one target that preferred that this be handled separately in each target rather than in target-independent legalization.
Repository:
rL LLVM
https://reviews.llvm.org/D41856
Files:
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.h
test/CodeGen/PowerPC/PR35812-neg-cmpxchg.ll
test/CodeGen/PowerPC/atomics-regression.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41856.129050.patch
Type: text/x-patch
Size: 18467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180109/2abbad15/attachment.bin>
More information about the llvm-commits
mailing list