diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index 20283ad8f2689..1c1c94e7193ae 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1663,10 +1663,13 @@ class ShuffleVectorSDNode : public SDNode { bool isSplat() const { return isSplatMask(getMask()); } - int getSplatIndex() const { - assert(isSplat() && "Cannot get splat index for non-splat!"); - EVT VT = getValueType(0); - for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) + int getSplatIndex() const { return getSplatMaskIndex(getMask()); } + + static bool isSplatMask(ArrayRef Mask); + + static int getSplatMaskIndex(ArrayRef Mask) { + assert(isSplatMask(Mask) && "Cannot get splat index for non-splat!"); + for (unsigned i = 0, e = Mask.size(); i != e; ++i) if (Mask[i] >= 0) return Mask[i]; @@ -1675,8 +1678,6 @@ class ShuffleVectorSDNode : public SDNode { return 0; } - static bool isSplatMask(ArrayRef Mask); - /// Change values in a shuffle permute mask assuming /// the two vector operands have swapped position. static void commuteMask(MutableArrayRef Mask) {