summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-12-03 21:17:51 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2019-12-03 21:34:12 +0300
commit444ac34182d562db2cb3b7d93d0d63acca1a6c9a (patch)
tree7a2ad1ed55f77457290fec7d2903d0d910a3d8d7 /llvm/unittests/IR
parent898df29c5b2ebbc4a24143e476d8e9a54569d2e5 (diff)
downloadbcm5719-llvm-444ac34182d562db2cb3b7d93d0d63acca1a6c9a.tar.gz
bcm5719-llvm-444ac34182d562db2cb3b7d93d0d63acca1a6c9a.zip
[APInt][PatternMatch] Add 'is non-positive' predicate
It will be useful for implementing the fold mentioned in https://bugs.llvm.org/show_bug.cgi?id=44100#c4
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r--llvm/unittests/IR/PatternMatch.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp
index 0c2ec36f878..80e0e92615a 100644
--- a/llvm/unittests/IR/PatternMatch.cpp
+++ b/llvm/unittests/IR/PatternMatch.cpp
@@ -182,6 +182,30 @@ TEST_F(PatternMatchTest, SpecificIntUGT) {
.match(NegOne));
}
+TEST_F(PatternMatchTest, SignbitZeroChecks) {
+ 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_TRUE(m_Negative().match(NegOne));
+ EXPECT_FALSE(m_NonNegative().match(NegOne));
+ EXPECT_FALSE(m_StrictlyPositive().match(NegOne));
+ EXPECT_TRUE(m_NonPositive().match(NegOne));
+
+ EXPECT_FALSE(m_Negative().match(Zero));
+ EXPECT_TRUE(m_NonNegative().match(Zero));
+ EXPECT_FALSE(m_StrictlyPositive().match(Zero));
+ EXPECT_TRUE(m_NonPositive().match(Zero));
+
+ EXPECT_FALSE(m_Negative().match(One));
+ EXPECT_TRUE(m_NonNegative().match(One));
+ EXPECT_TRUE(m_StrictlyPositive().match(One));
+ EXPECT_FALSE(m_NonPositive().match(One));
+}
+
TEST_F(PatternMatchTest, SpecificIntUGE) {
Type *IntTy = IRB.getInt32Ty();
unsigned BitWidth = IntTy->getScalarSizeInBits();
OpenPOWER on IntegriCloud