Fix two problems in SelectionDAGLegalize::ExpandBUILD_VECTOR's handling
authorChris Lattner <sabre@nondot.org>
Sun, 9 Mar 2008 00:29:42 +0000 (00:29 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 9 Mar 2008 00:29:42 +0000 (00:29 +0000)
commitf9d95c8835bc4f9072c33e1f9ebaa581a4d3268d
tree75c9d8c580279a177adf03a0f0e16a5cff6e9730
parentf3ba434781daa1c2b16f77a91e5209c21ce12428
Fix two problems in SelectionDAGLegalize::ExpandBUILD_VECTOR's handling
of BUILD_VECTORS that only have two unique elements:

1. The previous code was nondeterminstic, because it walked a map in
   SDOperand order, which isn't determinstic.
2. The previous code didn't handle the case when one element was undef
   very well.  Now we ensure that the generated shuffle mask has the
   undef vector on the RHS (instead of potentially being on the LHS)
   and that any elements that refer to it are themselves undef.  This
   allows us to compile CodeGen/X86/vec_set-9.ll into:

_test3:
movd %rdi, %xmm0
punpcklqdq %xmm0, %xmm0
ret

instead of:

_test3:
movd %rdi, %xmm1
#IMPLICIT_DEF %xmm0
punpcklqdq %xmm1, %xmm0
ret

... saving a register.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48060 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp