[LegalizeVectorTypes] When scalarizing the operand of a unary op like TRUNC, use...
authorCraig Topper <craig.topper@intel.com>
Fri, 2 Mar 2018 23:27:50 +0000 (23:27 +0000)
committerCraig Topper <craig.topper@intel.com>
Fri, 2 Mar 2018 23:27:50 +0000 (23:27 +0000)
commitdbf75c9c79910f8b99b2a273d886d8db3ff9b93e
treed9c65654013b5f9073185a48070e7a014c5dc215
parent702c14fd7954c1dfbf2bf156d99dfe36ac2920ba
[LegalizeVectorTypes] When scalarizing the operand of a unary op like TRUNC, use a SCALAR_TO_VECTOR rather than a single element BUILD_VECTOR to convert back to a vector type.

X86 considers v1i1 a legal type under AVX512 and as such a truncate from a v1iX type to v1i1 can be turned into a scalar truncate plus a conversion to v1i1. We would much prefer a v1i1 SCALAR_TO_VECTOR over a one element BUILD_VECTOR.

During lowering we were detecting the v1i1 BUILD_VECTOR as a splat BUILD_VECTOR like we try to do for v2i1/v4i1/etc. In this case we create (select i1 splat_elt, v1i1 all-ones, v1i1 all-zeroes). That goes through some more legalization and we end up with a CMOV choosing between 0 and 1 in scalar and a scalar_to_vector.

Arguably we could detect the v1i1 BUILD_VECTOR and do this better in X86 target code. But just using a SCALAR_TO_VECTOR in legalization is much easier.

llvm-svn: 326637
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/X86/avx512-load-trunc-store-i1.ll