summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/PatternMatch.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-07-25 13:34:14 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-07-25 13:34:14 +0000
commit6df3fc543303bf6755474b0c9ec669e67eef56cc (patch)
tree6fdfe962c019e0b14c3b995bc178fba615bab823 /llvm/unittests/IR/PatternMatch.cpp
parent38a02008687a21d69ffcd31a3dd42f1bc833b9b5 (diff)
downloadbcm5719-llvm-6df3fc543303bf6755474b0c9ec669e67eef56cc.tar.gz
bcm5719-llvm-6df3fc543303bf6755474b0c9ec669e67eef56cc.zip
[IR][PatternMatch] introduce m_Unless() matcher
Summary: I don't think it already exists? I don't see it at least. It is important to have it because else we'll do some checks after `match()`, and that may result in missed folds in commutative nodes. Reviewers: spatel, craig.topper, RKSimon, majnemer Reviewed By: spatel Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64037 llvm-svn: 367016
Diffstat (limited to 'llvm/unittests/IR/PatternMatch.cpp')
-rw-r--r--llvm/unittests/IR/PatternMatch.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp
index 600494fba26..8263acb59a0 100644
--- a/llvm/unittests/IR/PatternMatch.cpp
+++ b/llvm/unittests/IR/PatternMatch.cpp
@@ -454,6 +454,22 @@ TEST_F(PatternMatchTest, SpecificIntSLE) {
.match(NegOne));
}
+TEST_F(PatternMatchTest, Unless) {
+ Value *X = IRB.CreateAdd(IRB.getInt32(1), IRB.getInt32(0));
+
+ EXPECT_TRUE(m_Add(m_One(), m_Zero()).match(X));
+ EXPECT_FALSE(m_Add(m_Zero(), m_One()).match(X));
+
+ EXPECT_FALSE(m_Unless(m_Add(m_One(), m_Zero())).match(X));
+ EXPECT_TRUE(m_Unless(m_Add(m_Zero(), m_One())).match(X));
+
+ EXPECT_TRUE(m_c_Add(m_One(), m_Zero()).match(X));
+ EXPECT_TRUE(m_c_Add(m_Zero(), m_One()).match(X));
+
+ EXPECT_FALSE(m_Unless(m_c_Add(m_One(), m_Zero())).match(X));
+ EXPECT_FALSE(m_Unless(m_c_Add(m_Zero(), m_One())).match(X));
+}
+
TEST_F(PatternMatchTest, CommutativeDeferredValue) {
Value *X = IRB.getInt32(1);
Value *Y = IRB.getInt32(2);
OpenPOWER on IntegriCloud