[PATCH] D86430: [SelectionDAG] Fix miscompile bug in expandFunnelShift
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 00:30:07 PDT 2020
bjope created this revision.
bjope added reviewers: foad, arsenm, RKSimon.
Herald added subscribers: kerbowa, hiraditya, nhaehnle, jvesely.
Herald added a project: LLVM.
bjope requested review of this revision.
Herald added a subscriber: wdng.
This is a fixup of commit 0819a6416fd217 <https://reviews.llvm.org/rG0819a6416fd217413a1d04e93531db1b30272e9b> (D77152 <https://reviews.llvm.org/D77152>) which could
result in miscompiles. The miscompile could only happen for targets
where isOperationLegalOrCustom could return different values for
FSHL and FSHR.
The commit mentioned above added logic in expandFunnelShift to
convert between FSHL and FSHR by swapping direction of the
funnel shift. However, that transform is only legal if we know
that the shift count (modulo bitwidth) isn't zero.
Basically, since fshr(-1,0,0)==0 and fshl(-1,0,0)==-1 then doing a
rewrite such as fshr(X,Y,Z) => fshl(X,Y,0-Z) would be incorrect if
Z modulo bitwidth, could be zero.
It could be possible to add back the transform, given that logic
is added to check that (Z % BW) can't be zero. Since there were
no test cases proving that such a transform actually would be useful
I decided to simply remove the faulty code in this patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86430
Files:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/AMDGPU/fshl.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86430.287302.patch
Type: text/x-patch
Size: 17727 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200824/4cc5588f/attachment.bin>
More information about the llvm-commits
mailing list