OSDN Git Service

[x86] Teach the 128-bit vector shuffle lowering routines to take
authorChandler Carruth <chandlerc@gmail.com>
Mon, 16 Feb 2015 01:52:02 +0000 (01:52 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 16 Feb 2015 01:52:02 +0000 (01:52 +0000)
commit454c3997b4379acd0734a4fca289afc5c9a65425
tree9f3c2e9b8810d85af60a7578c14fc0fc1f62a3f6
parentaa35e012a3e454d654442d89a8f49ec1a7193403
[x86] Teach the 128-bit vector shuffle lowering routines to take
advantage of the existence of a reasonable blend instruction.

The 256-bit vector shuffle lowering has leveraged the general technique
of decomposed shuffles and blends for quite some time, but this never
made it back into the 128-bit code, and there are a large number of
patterns where this is substantially better. For example, this removes
almost all domain crossing in vector shuffles that involve some blend
and some permutation with SSE4.1 and later. See the massive reduction
in 'shufps' for integer test cases in this commit.

This isn't perfect yet for a few reasons:

1) The v8i16 shuffle lowering continues to plague me. We don't always
   form an unpack-based blend when that would be better. But the wins
   pretty drastically outstrip the losses here.
2) The v16i8 shuffle lowering is just a disaster here. I never went and
   implemented blend support here for some terrible reason. I'll do
   that next probably. I've not updated it for now.

More variations on this technique are coming as well -- we don't
shuffle-into-unpack or shuffle-into-palignr, both of which would also be
profitable.

Note that some test cases grow significantly in the number of
instructions, but I expect to actually be faster. We use
pshufd+pshufd+blendw instead of a single shufps, but the pshufd's are
very likely to pipeline well (two ports on most modern intel chips) and
the blend is a *very* fast instruction. The domain switch penalty will
essentially always be more than a blend instruction, which is the only
increase in tree height.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229350 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/SwizzleShuff.ll
test/CodeGen/X86/avx-trunc.ll
test/CodeGen/X86/combine-or.ll
test/CodeGen/X86/masked_memop.ll
test/CodeGen/X86/sse41.ll
test/CodeGen/X86/vector-idiv.ll
test/CodeGen/X86/vector-shuffle-128-v4.ll
test/CodeGen/X86/vector-shuffle-128-v8.ll
test/CodeGen/X86/vector-shuffle-256-v16.ll
test/CodeGen/X86/vector-shuffle-combining.ll
test/CodeGen/X86/vector-trunc.ll
test/CodeGen/X86/widen_shuffle-1.ll