[X86] Improve codegen of v8i64->v8i16 and v16i32->v16i8 truncate with avx512vl, avx51...
authorCraig Topper <craig.topper@intel.com>
Thu, 8 Aug 2019 21:36:47 +0000 (21:36 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 8 Aug 2019 21:36:47 +0000 (21:36 +0000)
commitc49d3e6c4d3b921227be32f20c2e5aeca1829917
tree6d9a0139d2bf02648fe47772ec057a0fcbf3d1b9
parent1d63b02f5305d18beca8945492b3775dc21ac0c7
[X86] Improve codegen of v8i64->v8i16 and v16i32->v16i8 truncate with avx512vl, avx512bw, min-legal-vector-width<=256 and prefer-vector-width=256

Under this configuration we'll want to split the v8i64 or v16i32 into two vectors. The default legalization will try to truncate each of those 256-bit pieces one step to 128-bit, concatenate those, then truncate one more time from the new 256 to 128 bits.

With this patch we now truncate the two splits to 64-bits then concatenate those. We have to do this two different ways depending on whether have widening legalization enabled. Without widening legalization we have to manually construct X86ISD::VTRUNC to prevent the ISD::TRUNCATE with a narrow result being promoted to 128 bits with a larger element type than what we want followed by something like a pshufb to grab the lower half of each element to finish the job. With widening legalization we just get the right thing. When we switch to widening by default we can just delete the other code path.

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

llvm-svn: 368349
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/min-legal-vector-width.ll