Skip to content

Commit f4878cb

Browse files
authored
[DAG] Add ShuffleVectorSDNode::getSplatMaskIndex static helper (#129731)
Move ShuffleVectorSDNode::getSplatIndex implementation into getSplatMaskIndex static helper, and covert getSplatIndex into a wrapper similar to isSplat
1 parent 652de78 commit f4878cb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,10 +1663,13 @@ class ShuffleVectorSDNode : public SDNode {
16631663

16641664
bool isSplat() const { return isSplatMask(getMask()); }
16651665

1666-
int getSplatIndex() const {
1667-
assert(isSplat() && "Cannot get splat index for non-splat!");
1668-
EVT VT = getValueType(0);
1669-
for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i)
1666+
int getSplatIndex() const { return getSplatMaskIndex(getMask()); }
1667+
1668+
static bool isSplatMask(ArrayRef<int> Mask);
1669+
1670+
static int getSplatMaskIndex(ArrayRef<int> Mask) {
1671+
assert(isSplatMask(Mask) && "Cannot get splat index for non-splat!");
1672+
for (unsigned i = 0, e = Mask.size(); i != e; ++i)
16701673
if (Mask[i] >= 0)
16711674
return Mask[i];
16721675

@@ -1675,8 +1678,6 @@ class ShuffleVectorSDNode : public SDNode {
16751678
return 0;
16761679
}
16771680

1678-
static bool isSplatMask(ArrayRef<int> Mask);
1679-
16801681
/// Change values in a shuffle permute mask assuming
16811682
/// the two vector operands have swapped position.
16821683
static void commuteMask(MutableArrayRef<int> Mask) {

0 commit comments

Comments
 (0)