summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-06-29 11:51:37 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-06-29 11:51:37 +0000
commitfe107fcde4d29a5d76ccbe9141a2fc8b5dd990f3 (patch)
tree7cf53e07a7d9507a811ca4148ebf526eb0546d45 /llvm/unittests
parent9e9eb62f9fd75706377ac6cf3abffad1328d0d4f (diff)
downloadbcm5719-llvm-fe107fcde4d29a5d76ccbe9141a2fc8b5dd990f3.tar.gz
bcm5719-llvm-fe107fcde4d29a5d76ccbe9141a2fc8b5dd990f3.zip
[IR][Patternmatch] Add m_SpecificInt_ULT() predicate
Summary: Match an integer or vector with every element unsigned less than the Threshold. For vectors, this includes constants with undefined elements. FIXME: is it worth generalizing this to simply take ICmpInst::Predicate? Reviewers: craig.topper, spatel, nikic Reviewed By: spatel Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63811 llvm-svn: 364711
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/IR/PatternMatch.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp
index de47975e7c6..8ea7a68b27c 100644
--- a/llvm/unittests/IR/PatternMatch.cpp
+++ b/llvm/unittests/IR/PatternMatch.cpp
@@ -64,6 +64,27 @@ TEST_F(PatternMatchTest, OneUse) {
EXPECT_FALSE(m_OneUse(m_Value()).match(Leaf));
}
+TEST_F(PatternMatchTest, SpecificIntULT) {
+ Type *IntTy = IRB.getInt32Ty();
+ unsigned BitWidth = IntTy->getScalarSizeInBits();
+
+ Value *Zero = ConstantInt::get(IntTy, 0);
+ Value *One = ConstantInt::get(IntTy, 1);
+ Value *NegOne = ConstantInt::get(IntTy, -1);
+
+ EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 0)).match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 0)).match(One));
+ EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 0)).match(NegOne));
+
+ EXPECT_TRUE(m_SpecificInt_ULT(APInt(BitWidth, 1)).match(Zero));
+ EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 1)).match(One));
+ EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, 1)).match(NegOne));
+
+ EXPECT_TRUE(m_SpecificInt_ULT(APInt(BitWidth, -1)).match(Zero));
+ EXPECT_TRUE(m_SpecificInt_ULT(APInt(BitWidth, -1)).match(One));
+ EXPECT_FALSE(m_SpecificInt_ULT(APInt(BitWidth, -1)).match(NegOne));
+}
+
TEST_F(PatternMatchTest, CommutativeDeferredValue) {
Value *X = IRB.getInt32(1);
Value *Y = IRB.getInt32(2);
OpenPOWER on IntegriCloud