[DAGCombiner] When combining EXTRACT_SUBVECTOR of a BUILD_VECTOR, make sure we don't create a BUILD_VECTOR with an illegal type after type legalization.

llvm-svn: 312621
This commit is contained in:
Craig Topper 2017-09-06 06:50:03 +00:00
parent 585bfc8443
commit 761bb1b53d
1 changed files with 3 additions and 2 deletions

View File

@ -15180,8 +15180,9 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode* N) {
unsigned NumElems = ExtractSize / EltSize; unsigned NumElems = ExtractSize / EltSize;
EVT ExtractVT = EVT::getVectorVT(*DAG.getContext(), EVT ExtractVT = EVT::getVectorVT(*DAG.getContext(),
InVT.getVectorElementType(), NumElems); InVT.getVectorElementType(), NumElems);
if (!LegalOperations || if ((!LegalOperations ||
TLI.isOperationLegal(ISD::BUILD_VECTOR, ExtractVT)) { TLI.isOperationLegal(ISD::BUILD_VECTOR, ExtractVT)) &&
(!LegalTypes || TLI.isTypeLegal(ExtractVT))) {
unsigned IdxVal = (Idx->getZExtValue() * NVT.getScalarSizeInBits()) / unsigned IdxVal = (Idx->getZExtValue() * NVT.getScalarSizeInBits()) /
EltSize; EltSize;