[x86,SDAG] Sink the logic for folding shuffles of splats more
authorChandler Carruth <chandlerc@gmail.com>
Tue, 8 Jul 2014 08:45:38 +0000 (08:45 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 8 Jul 2014 08:45:38 +0000 (08:45 +0000)
commit25b7d54e7ff322f5fc2bc1f356d554f0ee4b4be6
tree756b55a860bf9a6bf5d5f8ea31de81c24ee8643c
parent5b0b023a6414064a944808499f0718372def98a8
[x86,SDAG] Sink the logic for folding shuffles of splats more
aggressively from the x86 shuffle lowering to the generic SDAG vector
shuffle formation code.

This code already tried to fold away shuffles of splats! It just had
lots of bugs and couldn't handle the case my new x86 shuffle lowering
needed.

First, it failed to correctly compute whether N2 was undef because it
pre-computed this, then did transformations which could *make* N2 undef,
then failed to ever re-consider the precomputed state.

Second, it didn't look through bitcasts at all, even in the safe cases
where they are just element-type bitcasts with no change to the number
of elements.

Third, it didn't handle all-zero bit casts nicely the way my code in the
x86 side of things did, which is essential to getting good zext-shuffle
lowerings.

But all of these are generic. I just ported the code down to this layer
and fixed the surrounding bugs. Tests exercising this in the x86 backend
still pass and some silly code in widen_cast-6.ll gets better. I updated
that test to be a bit more precise but it's still pretty unclear what
the value of the test is in this day and age.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212517 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/widen_cast-6.ll