Skip to content

Commit 65ab88c

Browse files
author
Aidan
committed
changed SDShuffle_match to store Mask directly. Replaced the call to Mask.match() with a std::equal(mask,i->getMask(). changed matchVecShuffle test to not initialize Mask. Also added a test to compare contents of MaskData to Mask.
1 parent 1b3dd6f commit 65ab88c

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,19 +550,19 @@ struct BinaryOpc_match {
550550
};
551551

552552
/// Matches shuffle.
553-
template <typename T0, typename T1, typename T2> struct SDShuffle_match {
553+
template <typename T0, typename T1> struct SDShuffle_match {
554554
T0 Op1;
555555
T1 Op2;
556-
T2 Mask;
556+
ArrayRef<int> Mask;
557557

558-
SDShuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
558+
SDShuffle_match(const T0 &Op1, const T1 &Op2, const ArrayRef<int> &Mask)
559559
: Op1(Op1), Op2(Op2), Mask(Mask) {}
560560

561561
template <typename MatchContext>
562562
bool match(const MatchContext &Ctx, SDValue N) {
563563
if (auto *I = dyn_cast<ShuffleVectorSDNode>(N)) {
564564
return Op1.match(Ctx, I->getOperand(0)) &&
565-
Op2.match(Ctx, I->getOperand(1)) && Mask.match(I->getMask());
565+
Op2.match(Ctx, I->getOperand(1)) && std::equal(Mask.begin(), Mask.end(), I->getMask().begin());
566566
}
567567
return false;
568568
}
@@ -822,10 +822,10 @@ inline BinaryOpc_match<LHS, RHS> m_Shuffle(const LHS &v1, const RHS &v2) {
822822
return BinaryOpc_match<LHS, RHS>(ISD::VECTOR_SHUFFLE, v1, v2);
823823
}
824824

825-
template <typename V1_t, typename V2_t, typename Mask_t>
826-
inline SDShuffle_match<V1_t, V2_t, Mask_t>
827-
m_Shuffle(const V1_t &v1, const V2_t &v2, const Mask_t &mask) {
828-
return SDShuffle_match<V1_t, V2_t, Mask_t>(v1, v2, mask);
825+
template <typename V1_t, typename V2_t>
826+
inline SDShuffle_match<V1_t, V2_t>
827+
m_Shuffle(const V1_t &v1, const V2_t &v2, const ArrayRef<int> mask) {
828+
return SDShuffle_match<V1_t, V2_t>(v1, v2, mask);
829829
}
830830

831831
// === Unary operations ===

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ TEST_F(SelectionDAGPatternMatchTest, matchVecShuffle) {
124124
auto Int32VT = EVT::getIntegerVT(Context, 32);
125125
auto VInt32VT = EVT::getVectorVT(Context, Int32VT, 4);
126126
SmallVector<int, 4> MaskData = {2, 0, 3, 1};
127-
ArrayRef<int> Mask(MaskData);
127+
ArrayRef<int> Mask;
128128

129129
SDValue V0 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 1, VInt32VT);
130130
SDValue V1 = DAG->getCopyFromReg(DAG->getEntryNode(), DL, 2, VInt32VT);
@@ -135,7 +135,8 @@ TEST_F(SelectionDAGPatternMatchTest, matchVecShuffle) {
135135
EXPECT_TRUE(
136136
sd_match(VecShuffleWithMask_0, m_Shuffle(m_Value(V0), m_Value(V1))));
137137
EXPECT_TRUE(sd_match(VecShuffleWithMask_0,
138-
m_Shuffle(m_Value(V0), m_Value(V1), m_Mask(Mask))));
138+
m_Shuffle(m_Value(V0), m_Value(V1), Mask)));
139+
EXPECT_TRUE(std::equal(Mask.begin(), Mask.end(), MaskData.begin()));
139140
}
140141

141142
TEST_F(SelectionDAGPatternMatchTest, matchTernaryOp) {

0 commit comments

Comments
 (0)