[X86] Don't fold non-LSB extracts into truncating broadcasts.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 6 Nov 2015 23:16:38 +0000 (23:16 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 6 Nov 2015 23:16:38 +0000 (23:16 +0000)
commitb1769420b8b081bfa3fe41555b78a9d57264b641
treea75142d33009c5baa48a2d7e0dcc3f58e410feac
parent136bd632b6624b46f541b9bab2bdc3a558c0440b
[X86] Don't fold non-LSB extracts into truncating broadcasts.

We used to incorrectly assume that the offset we're extracting from
was a multiple of the element size. So, we'd fold:
  (v8i16 (shufflevector
    (v8i16 (bitcast (v4i32 (build_vector X, Y, ...)))),
    <1,1,...,1>))
into:
  (v8i16 (vbroadcast (i16 (trunc Y))))
whereas we should have extracted the higher bits from X.

Instead, bail out if the assumption doesn't hold.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252361 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/vector-shuffle-128-v16.ll
test/CodeGen/X86/vector-shuffle-128-v8.ll
test/CodeGen/X86/vector-shuffle-256-v16.ll
test/CodeGen/X86/vector-shuffle-256-v32.ll