Skip to content

Commit 1d58699

Browse files
authored
[SDPatternMatch] Add Matcher m_Undef (#122521)
Add Matcher `m_Undef` Fixes: #122439
1 parent 876fa60 commit 1d58699

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ struct Opcode_match {
138138

139139
inline Opcode_match m_Opc(unsigned Opcode) { return Opcode_match(Opcode); }
140140

141+
inline Opcode_match m_Undef() { return Opcode_match(ISD::UNDEF); }
142+
141143
template <unsigned NumUses, typename Pattern> struct NUses_match {
142144
Pattern P;
143145

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ TEST_F(SelectionDAGPatternMatchTest, matchConstants) {
474474
EXPECT_EQ(CC, ISD::SETULT);
475475
EXPECT_TRUE(sd_match(SetCC, m_Node(ISD::SETCC, m_Value(), m_Value(),
476476
m_SpecificCondCode(ISD::SETULT))));
477+
478+
SDValue UndefInt32VT = DAG->getUNDEF(Int32VT);
479+
SDValue UndefVInt32VT = DAG->getUNDEF(VInt32VT);
480+
EXPECT_TRUE(sd_match(UndefInt32VT, m_Undef()));
481+
EXPECT_TRUE(sd_match(UndefVInt32VT, m_Undef()));
477482
}
478483

479484
TEST_F(SelectionDAGPatternMatchTest, patternCombinators) {

0 commit comments

Comments
 (0)