Skip to content

Commit

Permalink
[SDPatternMatch] Add Matcher m_Undef (#122521)
Browse files Browse the repository at this point in the history
Add Matcher `m_Undef`

Fixes: #122439
  • Loading branch information
AmrDeveloper authored Jan 11, 2025
1 parent 876fa60 commit 1d58699
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/include/llvm/CodeGen/SDPatternMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ struct Opcode_match {

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

inline Opcode_match m_Undef() { return Opcode_match(ISD::UNDEF); }

template <unsigned NumUses, typename Pattern> struct NUses_match {
Pattern P;

Expand Down
5 changes: 5 additions & 0 deletions llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ TEST_F(SelectionDAGPatternMatchTest, matchConstants) {
EXPECT_EQ(CC, ISD::SETULT);
EXPECT_TRUE(sd_match(SetCC, m_Node(ISD::SETCC, m_Value(), m_Value(),
m_SpecificCondCode(ISD::SETULT))));

SDValue UndefInt32VT = DAG->getUNDEF(Int32VT);
SDValue UndefVInt32VT = DAG->getUNDEF(VInt32VT);
EXPECT_TRUE(sd_match(UndefInt32VT, m_Undef()));
EXPECT_TRUE(sd_match(UndefVInt32VT, m_Undef()));
}

TEST_F(SelectionDAGPatternMatchTest, patternCombinators) {
Expand Down

0 comments on commit 1d58699

Please sign in to comment.