[x86] Generalize BuildVectorSDNode::getConstantSplatValue to work for
authorChandler Carruth <chandlerc@gmail.com>
Fri, 4 Jul 2014 08:11:49 +0000 (08:11 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 4 Jul 2014 08:11:49 +0000 (08:11 +0000)
commita46e60eb2ed110468d9d51c38f92f16732140274
treed3a3d81d95201515f3d33518ffc0869df3087dc5
parentc5bc1525343121689ee319412845e57314325795
[x86] Generalize BuildVectorSDNode::getConstantSplatValue to work for
any constant, constant FP, or undef splat and to tolerate any undef
lanes in a splat, then replace all uses of isSplatVector in X86's
lowering with it.

This fixes issues where undef lanes in an otherwise splat vector would
prevent the splat logic from firing. It is a touch more awkward to use
this interface, but it is much more accurate. Suggestions for better
interface structuring welcome.

With this fix, the code generated with the widening legalization
strategy for widen_cast-4.ll is *dramatically* improved as the special
lowering strategies for a v16i8 SRA kick in even though the high lanes
are undef.

We also get a slightly different choice for broadcasting an aligned
memory location, and use vpshufd instead of vbroadcastss. This looks
like a minor win for pipelining and domain crossing, but a minor loss
for the number of micro-ops. I suspect its a wash, but folks can easily
tweak the lowering if they want.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212324 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/vector-gep.ll
test/CodeGen/X86/widen_cast-4.ll