[X86] Teach the backend how to lower vector shift left into multiply rather than...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 12 Feb 2014 23:42:28 +0000 (23:42 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 12 Feb 2014 23:42:28 +0000 (23:42 +0000)
commit88873717824208d6d2f8f34bf727550fba1c590d
tree3635436ebb25a1f2fcaaa1f5c32d15d9cfefae07
parent67ee127f1a7a90faf5c8fbecf19885bc45591c85
[X86] Teach the backend how to lower vector shift left into multiply rather than scalarizing it.

Instead of expanding a packed shift into a sequence of scalar shifts,
the backend now tries (when possible) to convert the vector shift into a
vector multiply.

Before this change, a shift of a MVT::v8i16 vector by a
build_vector of constants was always scalarized into a long sequence of "vector
extracts + scalar shifts + vector insert".
With this change, if there is SSE2 support, we emit a single vector multiply.

This change also affects SSE4.1, AVX, AVX2 shifts:
 - A shift of a MVT::v4i32 vector by a build_vector of non uniform constants
is now lowered when possible into a single SSE4.1 vector multiply.
 - Packed v16i16 shift left by constant build_vector are now expanded when
possible into a single AVX2 vpmullw.
This change also improves the lowering of AVX512f vector shifts.

Added test CodeGen/X86/vec_shift6.ll with some code examples that are affected
by this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201271 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/avx-shift.ll
test/CodeGen/X86/vec_shift6.ll [new file with mode: 0644]