[x86] Re-apply a variant of the x86 side of r212324 now that the rest
authorChandler Carruth <chandlerc@gmail.com>
Wed, 9 Jul 2014 10:06:58 +0000 (10:06 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 9 Jul 2014 10:06:58 +0000 (10:06 +0000)
commit2ebc9426837be456e5c1ce8b1bee675e73ad5091
treee5635f525b7fdbb9a444528f7ea381f46ad4c094
parent4c8c903b59b203cc104d8ae18a10d0437ac3fc20
[x86] Re-apply a variant of the x86 side of r212324 now that the rest
has settled without incident, removing the x86-specific and overly
strict 'isVectorSplat' routine in favor of generic and more powerful
splat detection.

The primary motivation and result of this is that the x86 backend can
now see through splats which contain undef elements. This is essential
if we are using a widening form of legalization and I've updated a test
case to also run in that mode as before this change the generated code
for the test case was completely scalarized.

This version of the patch much more carefully handles the undef lanes.
- We aren't overly conservative about them in the shift lowering
  (where we will never use the splat itself).
- One place where the splat would have been re-used by the existing code
  now explicitly constructs a new constant splat that will be safe.
- The broadcast lowering is much more reasonable with undefs by doing
  a correct check of whether the splat is the only user of a loaded
  value, checking that the splat actually crosses multiple lanes before
  using a broadcast, and handling broadcasts of non-constant splats.

As a consequence of the last bullet, the weird usage of vpshufd instead
of vbroadcast is gone, and we actually can lower an AVX splat with
vbroadcastss where before we emitted a really strange pattern of
a vector load and a manual splat across the vector.

llvm-svn: 212602
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx-splat.ll
llvm/test/CodeGen/X86/widen_cast-4.ll