diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h index fc8ef717c74f6..a2495267ee352 100644 --- a/llvm/include/llvm/CodeGen/SDPatternMatch.h +++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h @@ -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 struct NUses_match { Pattern P; diff --git a/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp b/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp index a2e1e588d03de..24d1b7f855160 100644 --- a/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp +++ b/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp @@ -436,6 +436,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) {