Skip to content

Commit e4016bf

Browse files
committed
[DAG] Use ArrayRef to simplify ShuffleVectorSDNode::isSplatMask
1 parent 67e1e98 commit e4016bf

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ class ShuffleVectorSDNode : public SDNode {
16451645
return Mask[Idx];
16461646
}
16471647

1648-
bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
1648+
bool isSplat() const { return isSplatMask(getMask()); }
16491649

16501650
int getSplatIndex() const {
16511651
assert(isSplat() && "Cannot get splat index for non-splat!");
@@ -1659,7 +1659,7 @@ class ShuffleVectorSDNode : public SDNode {
16591659
return 0;
16601660
}
16611661

1662-
static bool isSplatMask(const int *Mask, EVT VT);
1662+
static bool isSplatMask(ArrayRef<int> Mask);
16631663

16641664
/// Change values in a shuffle permute mask assuming
16651665
/// the two vector operands have swapped position.

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13415,10 +13415,10 @@ BuildVectorSDNode::isConstantSequence() const {
1341513415
return std::make_pair(Start, Stride);
1341613416
}
1341713417

13418-
bool ShuffleVectorSDNode::isSplatMask(const int *Mask, EVT VT) {
13418+
bool ShuffleVectorSDNode::isSplatMask(ArrayRef<int> Mask) {
1341913419
// Find the first non-undef value in the shuffle mask.
1342013420
unsigned i, e;
13421-
for (i = 0, e = VT.getVectorNumElements(); i != e && Mask[i] < 0; ++i)
13421+
for (i = 0, e = Mask.size(); i != e && Mask[i] < 0; ++i)
1342213422
/* search */;
1342313423

1342413424
// If all elements are undefined, this shuffle can be considered a splat

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15508,7 +15508,7 @@ bool AArch64TargetLowering::isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const {
1550815508

1550915509
unsigned EltSize = VT.getScalarSizeInBits();
1551015510
unsigned NumElts = VT.getVectorNumElements();
15511-
return (ShuffleVectorSDNode::isSplatMask(&M[0], VT) ||
15511+
return (ShuffleVectorSDNode::isSplatMask(M) ||
1551215512
isREVMask(M, EltSize, NumElts, 64) ||
1551315513
isREVMask(M, EltSize, NumElts, 32) ||
1551415514
isREVMask(M, EltSize, NumElts, 16) ||

llvm/lib/Target/ARM/ARMISelLowering.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8479,7 +8479,7 @@ bool ARMTargetLowering::isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const {
84798479

84808480
unsigned EltSize = VT.getScalarSizeInBits();
84818481
if (EltSize >= 32 ||
8482-
ShuffleVectorSDNode::isSplatMask(&M[0], VT) ||
8482+
ShuffleVectorSDNode::isSplatMask(M) ||
84838483
ShuffleVectorInst::isIdentityMask(M, M.size()) ||
84848484
isVREVMask(M, VT, 64) ||
84858485
isVREVMask(M, VT, 32) ||

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -5790,8 +5790,8 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
57905790
// as a vselect + a single source vrgather.vv. Don't do this if we think the
57915791
// operands may end up being lowered to something cheaper than a vrgather.vv.
57925792
if (!DAG.isSplatValue(V2) && !DAG.isSplatValue(V1) &&
5793-
!ShuffleVectorSDNode::isSplatMask(ShuffleMaskLHS.data(), VT) &&
5794-
!ShuffleVectorSDNode::isSplatMask(ShuffleMaskRHS.data(), VT) &&
5793+
!ShuffleVectorSDNode::isSplatMask(ShuffleMaskLHS) &&
5794+
!ShuffleVectorSDNode::isSplatMask(ShuffleMaskRHS) &&
57955795
!ShuffleVectorInst::isIdentityMask(ShuffleMaskLHS, NumElts) &&
57965796
!ShuffleVectorInst::isIdentityMask(ShuffleMaskRHS, NumElts))
57975797
if (SDValue V = lowerDisjointIndicesShuffle(SVN, DAG, Subtarget))
@@ -5834,7 +5834,7 @@ bool RISCVTargetLowering::isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const {
58345834
return false;
58355835

58365836
// Support splats for any type. These should type legalize well.
5837-
if (ShuffleVectorSDNode::isSplatMask(M.data(), VT))
5837+
if (ShuffleVectorSDNode::isSplatMask(M))
58385838
return true;
58395839

58405840
const unsigned NumElts = M.size();

0 commit comments

Comments
 (0)