Skip to content

Commit bb51c5d

Browse files
authored
[SDPatternMatch] Add m_Poison matcher (#144860)
Add SDPatternMatch matcher and unit test coverage for ISD::POISON opcode e.g. ``` m_InsertElt(m_Poison(), m_Value(), m_Zero()) ```
1 parent 50c5ecd commit bb51c5d

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
@@ -142,6 +142,8 @@ inline Opcode_match m_Opc(unsigned Opcode) { return Opcode_match(Opcode); }
142142

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

145+
inline Opcode_match m_Poison() { return Opcode_match(ISD::POISON); }
146+
145147
template <unsigned NumUses, typename Pattern> struct NUses_match {
146148
Pattern P;
147149

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,11 @@ TEST_F(SelectionDAGPatternMatchTest, matchConstants) {
493493
SDValue UndefVInt32VT = DAG->getUNDEF(VInt32VT);
494494
EXPECT_TRUE(sd_match(UndefInt32VT, m_Undef()));
495495
EXPECT_TRUE(sd_match(UndefVInt32VT, m_Undef()));
496+
497+
SDValue PoisonInt32VT = DAG->getPOISON(Int32VT);
498+
SDValue PoisonVInt32VT = DAG->getPOISON(VInt32VT);
499+
EXPECT_TRUE(sd_match(PoisonInt32VT, m_Poison()));
500+
EXPECT_TRUE(sd_match(PoisonVInt32VT, m_Poison()));
496501
}
497502

498503
TEST_F(SelectionDAGPatternMatchTest, patternCombinators) {

0 commit comments

Comments
 (0)