OSDN Git Service

[DAGCombiner] eliminate shuffle of insert element
authorSanjay Patel <spatel@rotateright.com>
Thu, 7 Dec 2017 15:17:58 +0000 (15:17 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 7 Dec 2017 15:17:58 +0000 (15:17 +0000)
commitc36b1d69e04825be748b676d26167ed35a18a929
treef3498deacc096912f9bb890a4323748ed6099d70
parente18338969d0ed13427863fb23fa4a5c8e8df0b14
[DAGCombiner] eliminate shuffle of insert element

I noticed this pattern in D38316 / D38388. We failed to combine a shuffle that is either
repeating a scalar insertion at the same position in a vector or translated to a different
element index.

Like the earlier patch, this could be an instcombine too, but since we opted to make this
a DAG transform earlier, I've made this one a DAG patch too.

We do not need any legality checking because the new insert is identical to the existing
insert except that it may have a different constant insertion operand.

The constant insertion test in test/CodeGen/X86/vector-shuffle-combining.ll was the
motivation for D38756.

Differential Revision: https://reviews.llvm.org/D40209

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320050 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/shuffle-of-insert.ll
test/CodeGen/X86/sse41.ll
test/CodeGen/X86/vector-shuffle-128-v2.ll
test/CodeGen/X86/vector-shuffle-combining.ll