Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2279,12 +2279,15 @@ /// across all DemandedElts. bool SelectionDAG::isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts) { - if (!DemandedElts) - return false; // No demanded elts, better to assume we don't know anything. - EVT VT = V.getValueType(); assert(VT.isVector() && "Vector type expected"); + if (V.getOpcode() == ISD::SPLAT_VECTOR) + return true; + + if (!DemandedElts || VT.isScalableVector()) + return false; // No demanded elts, better to assume we don't know anything. + unsigned NumElts = VT.getVectorNumElements(); assert(NumElts == DemandedElts.getBitWidth() && "Vector size mismatch"); UndefElts = APInt::getNullValue(NumElts); @@ -2363,7 +2366,8 @@ bool SelectionDAG::isSplatValue(SDValue V, bool AllowUndefs) { EVT VT = V.getValueType(); assert(VT.isVector() && "Vector type expected"); - unsigned NumElts = VT.getVectorNumElements(); + // For now we don't support this with scalable vectors. + unsigned NumElts = VT.isScalableVector() ? 0 : VT.getVectorNumElements(); APInt UndefElts; APInt DemandedElts = APInt::getAllOnesValue(NumElts); @@ -2378,6 +2382,9 @@ unsigned Opcode = V.getOpcode(); switch (Opcode) { default: { + if (VT.isScalableVector()) + return SDValue(); + APInt UndefElts; APInt DemandedElts = APInt::getAllOnesValue(VT.getVectorNumElements()); if (isSplatValue(V, DemandedElts, UndefElts)) { @@ -2391,6 +2398,8 @@ } break; } + case ISD::SPLAT_VECTOR: + return V; case ISD::VECTOR_SHUFFLE: { // Check if this is a shuffle node doing a splat. // TODO - remove this and rely purely on SelectionDAG::isSplatValue,