diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4315,8 +4315,8 @@ return Ops[0].getValueType() == Op.getValueType(); }) && "Concatenation of vectors with inconsistent value types!"); - assert((Ops.size() * Ops[0].getValueType().getVectorNumElements()) == - VT.getVectorNumElements() && + assert((Ops[0].getValueType().getVectorElementCount() * Ops.size()) == + VT.getVectorElementCount() && "Incorrect element count in vector concatenation!"); if (Ops.size() == 1) @@ -4333,7 +4333,7 @@ bool IsIdentity = true; for (unsigned i = 0, e = Ops.size(); i != e; ++i) { SDValue Op = Ops[i]; - unsigned IdentityIndex = i * Op.getValueType().getVectorNumElements(); + unsigned IdentityIndex = i * Op.getValueType().getVectorMinNumElements(); if (Op.getOpcode() != ISD::EXTRACT_SUBVECTOR || Op.getOperand(0).getValueType() != VT || (IdentitySrc && Op.getOperand(0) != IdentitySrc) || @@ -4350,6 +4350,11 @@ return IdentitySrc; } + // The code below this point is only designed to work for fixed width + // vectors, so we bail out for now. + if (VT.isScalableVector()) + return SDValue(); + // A CONCAT_VECTOR with all UNDEF/BUILD_VECTOR operands can be // simplified to one big BUILD_VECTOR. // FIXME: Add support for SCALAR_TO_VECTOR as well.