[x86] Teach the x86 vector shuffle lowering to detect mergable 128-bit
authorChandler Carruth <chandlerc@gmail.com>
Fri, 21 Nov 2014 13:56:05 +0000 (13:56 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 21 Nov 2014 13:56:05 +0000 (13:56 +0000)
commitd2b19bc867ee14c93e6ec72b28f25efb8ab8e179
tree7571bffa5699caaff40d9316756065ddd1f4699e
parent8a3934f85b9ebc171f162f5328219a482bf21ff9
[x86] Teach the x86 vector shuffle lowering to detect mergable 128-bit
lanes.

By special casing these we can often either reduce the total number of
shuffles significantly or reduce the number of (high latency on Haswell)
AVX2 shuffles that potentially cross 128-bit lanes. Even when these
don't actually cross lanes, they have much higher latency to support
that. Doing two of them and a blend is worse than doing a single insert
across the 128-bit lanes to blend and then doing a single interleaved
shuffle.

While this seems like a narrow case, it kept cropping up on me and the
difference is *huge* as you can see in many of the test cases. I first
hit this trying to perfectly fix the interleaving shuffle patterns used
by Halide for AVX2.

llvm-svn: 222533
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx-vperm2x128.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v16.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v32.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v4.ll
llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll
llvm/test/CodeGen/X86/vector-shuffle-512-v8.ll
llvm/test/CodeGen/X86/vector-shuffle-combining.ll