[DAGCombiner] simplify shuffle of shuffle
authorSanjay Patel <spatel@rotateright.com>
Fri, 29 Mar 2019 14:20:38 +0000 (14:20 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 29 Mar 2019 14:20:38 +0000 (14:20 +0000)
commit12685d0f7cd870b64aff47016f2bc4cd7210fb14
treec739c3a15941de1e421a9205ac8e90e5a26b44a1
parent9b41a7320dc6aee2008273ad5198c90444c6d5bd
[DAGCombiner] simplify shuffle of shuffle

After investigating the examples from D59777 targeting an SSE4.1 machine,
it looks like a very different problem due to how we map illegal types (256-bit in these cases).

We're missing a shuffle simplification that maps elements of a vector back to a shuffled operand.
We have a more general version of this transform in DAGCombiner::visitVECTOR_SHUFFLE(), but that
generality means it is limited to patterns with a one-use constraint, and the examples here have
2 uses. We don't need any uses or legality limitations for a simplification (no new value is
created).

It looks like we miss this pattern in IR too.

In one of the zext examples here, we have shuffle masks like this:

Shuf0 = vector_shuffle<0,u,3,7,0,u,3,7>
Shuf = vector_shuffle<4,u,6,7,u,u,u,u>

...so that's moving the high half of the 1st vector into the low half. But the high half of the
1st vector is already identical to the low half.

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

llvm-svn: 357258
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/vector-zext.ll