[PATCH] D66965: [InstCombine] recognize bswap disguised as shufflevector
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 10:51:57 PDT 2019
spatel created this revision.
spatel added reviewers: efriedma, lebedev.ri, craig.topper.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.
bitcast <N x i8> (shuf X, undef, <N, N-1,...0>) to i{N*8}--> bswap (bitcast X to i{N*8})
In PR43146:
https://bugs.llvm.org/show_bug.cgi?id=43146
...we have a more complicated case where SLP is making a mess of bswap. This patch won't do anything for that currently, but we need to improve bswap recognition in instcombine, SLP, and/or a standalone pass to avoid that problem.
This is limited using the data-layout so we don't try to do this transform with actual vector types. The backend does not appear to have folds to convert in either direction, so we don't want to mess up something that is actually better lowered as a shuffle.
On x86, we're trading something like this:
vmovd %edi, %xmm0
vpshufb LCPI0_0(%rip), %xmm0, %xmm0 ## xmm0 = xmm0[3,2,1,0,u,u,u,u,u,u,u,u,u,u,u,u]
vmovd %xmm0, %eax
For:
movl %edi, %eax
bswapl %eax
https://reviews.llvm.org/D66965
Files:
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/bswap.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66965.217937.patch
Type: text/x-patch
Size: 5267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190829/d8b2da72/attachment.bin>
More information about the llvm-commits
mailing list