[X86] Add a custom legalization for (i16 (bitcast v16i1)) and (i32 (bitcast v32i1...
authorCraig Topper <craig.topper@intel.com>
Mon, 26 Feb 2018 20:32:27 +0000 (20:32 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 26 Feb 2018 20:32:27 +0000 (20:32 +0000)
commit5e0ceb88658e5075b03f8c6df4f71027318fe9cd
tree9428a405622bbbf526e49e9a53ab6f9c26288230
parent6daad9da6d87f806050c44cd8a96a7631e14f6a4
[X86] Add a custom legalization for (i16 (bitcast v16i1)) and (i32 (bitcast v32i1)) without AVX512 to prevent scalarization

Summary:
We have an early DAG combine to turn these patterns into MOVMSK, but that combine doesn't work if the vXi1 type has more elements than the widest legal vXi8 type. Type legalization will eventually split it down to v16i1 or v32i1 and then the bitcast gets legalized to a truncstore and a scalar load. The truncstore will get lowered to a series of extracts and bit math.

This patch adds a custom legalization to use a sign extend and MOVMSK instead. This prevents the eventual scalarization.

Reviewers: spatel, RKSimon, zvi

Reviewed By: RKSimon

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D43593

llvm-svn: 326119
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/bitcast-and-setcc-512.ll
llvm/test/CodeGen/X86/bitcast-setcc-128.ll
llvm/test/CodeGen/X86/bitcast-setcc-512.ll