Skip to content

[DAG] Add ShuffleVectorSDNode::getSplatMaskIndex static helper #129731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions llvm/include/llvm/CodeGen/SelectionDAGNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> Mask);

static int getSplatMaskIndex(ArrayRef<int> 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];

Expand All @@ -1675,8 +1678,6 @@ class ShuffleVectorSDNode : public SDNode {
return 0;
}

static bool isSplatMask(ArrayRef<int> Mask);

/// Change values in a shuffle permute mask assuming
/// the two vector operands have swapped position.
static void commuteMask(MutableArrayRef<int> Mask) {
Expand Down