Skip to content

Commit a387126

Browse files
committed
Add unit tests for m_NotForbidPoison
This is kind of the replacement for the m_NotForbidUndef matcher we used to have.
1 parent 2bf2afa commit a387126

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

llvm/unittests/IR/PatternMatch.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,7 @@ TEST_F(PatternMatchTest, VScale) {
19951995
EXPECT_TRUE(match(PtrToInt2, m_VScale()));
19961996
}
19971997

1998-
TEST_F(PatternMatchTest, NotForbidUndef) {
1998+
TEST_F(PatternMatchTest, NotForbidPoison) {
19991999
Type *ScalarTy = IRB.getInt8Ty();
20002000
Type *VectorTy = FixedVectorType::get(ScalarTy, 3);
20012001
Constant *ScalarUndef = UndefValue::get(ScalarTy);
@@ -2020,23 +2020,33 @@ TEST_F(PatternMatchTest, NotForbidUndef) {
20202020
Value *X;
20212021
EXPECT_TRUE(match(Not, m_Not(m_Value(X))));
20222022
EXPECT_TRUE(match(X, m_Zero()));
2023+
X = nullptr;
2024+
EXPECT_TRUE(match(Not, m_NotForbidPoison(m_Value(X))));
2025+
EXPECT_TRUE(match(X, m_Zero()));
20232026

20242027
Value *NotCommute = IRB.CreateXor(VectorOnes, VectorZero);
20252028
Value *Y;
20262029
EXPECT_TRUE(match(NotCommute, m_Not(m_Value(Y))));
20272030
EXPECT_TRUE(match(Y, m_Zero()));
2031+
Y = nullptr;
2032+
EXPECT_TRUE(match(NotCommute, m_NotForbidPoison(m_Value(Y))));
2033+
EXPECT_TRUE(match(Y, m_Zero()));
20282034

20292035
Value *NotWithUndefs = IRB.CreateXor(VectorZero, VectorMixedUndef);
20302036
EXPECT_FALSE(match(NotWithUndefs, m_Not(m_Value())));
2037+
EXPECT_FALSE(match(NotWithUndefs, m_NotForbidPoison(m_Value())));
20312038

20322039
Value *NotWithPoisons = IRB.CreateXor(VectorZero, VectorMixedPoison);
20332040
EXPECT_TRUE(match(NotWithPoisons, m_Not(m_Value())));
2041+
EXPECT_FALSE(match(NotWithPoisons, m_NotForbidPoison(m_Value())));
20342042

20352043
Value *NotWithUndefsCommute = IRB.CreateXor(VectorMixedUndef, VectorZero);
20362044
EXPECT_FALSE(match(NotWithUndefsCommute, m_Not(m_Value())));
2045+
EXPECT_FALSE(match(NotWithUndefsCommute, m_NotForbidPoison(m_Value())));
20372046

20382047
Value *NotWithPoisonsCommute = IRB.CreateXor(VectorMixedPoison, VectorZero);
20392048
EXPECT_TRUE(match(NotWithPoisonsCommute, m_Not(m_Value())));
2049+
EXPECT_FALSE(match(NotWithPoisonsCommute, m_NotForbidPoison(m_Value())));
20402050
}
20412051

20422052
template <typename T> struct MutableConstTest : PatternMatchTest { };

0 commit comments

Comments
 (0)