Skip to content

Commit e9987c6

Browse files
author
Aidan
committed
only capture mask if ops match. reordered tests
1 parent d818fd5 commit e9987c6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,11 @@ template <typename T0, typename T1> struct SDShuffle_match {
554554
template <typename MatchContext>
555555
bool match(const MatchContext &Ctx, SDValue N) {
556556
if (auto *I = dyn_cast<ShuffleVectorSDNode>(N)) {
557-
CapturedMask = I->getMask();
558-
return Op1.match(Ctx, I->getOperand(0)) &&
559-
Op2.match(Ctx, I->getOperand(1));
557+
if (Op1.match(Ctx, I->getOperand(0)) &&
558+
Op2.match(Ctx, I->getOperand(1))) {
559+
CapturedMask = I->getMask();
560+
return true;
561+
}
560562
}
561563
return false;
562564
}

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ TEST_F(SelectionDAGPatternMatchTest, matchVecShuffle) {
137137
m_Shuffle(m_Value(), m_Value(), CapturedMask)));
138138
EXPECT_TRUE(sd_match(VecShuffleWithMask,
139139
m_ShuffleSpecificMask(m_Value(), m_Value(), MaskData)));
140-
EXPECT_TRUE(std::equal(MaskData.begin(), MaskData.end(), CapturedMask.begin(),
141-
CapturedMask.end()));
142140
EXPECT_FALSE(
143141
sd_match(VecShuffleWithMask,
144142
m_ShuffleSpecificMask(m_Value(), m_Value(), otherMaskData)));
143+
144+
EXPECT_TRUE(std::equal(MaskData.begin(), MaskData.end(), CapturedMask.begin(),
145+
CapturedMask.end()));
145146
EXPECT_FALSE(std::equal(otherMaskData.begin(), otherMaskData.end(),
146147
CapturedMask.begin(), CapturedMask.end()));
147148
}

0 commit comments

Comments
 (0)