diff options
author | Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> | 2024-07-03 10:50:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-03 10:50:22 +0100 |
commit | edbbc832a5308e4f6943583965e74254799f13ae (patch) | |
tree | 4f1ab3ab72bec44382004798b64b923e51236002 /llvm/unittests/IR/ConstantRangeTest.cpp | |
parent | 5a1a46722948b79803826f1b11877ffcf102c094 (diff) | |
download | llvm-edbbc832a5308e4f6943583965e74254799f13ae.zip llvm-edbbc832a5308e4f6943583965e74254799f13ae.tar.gz llvm-edbbc832a5308e4f6943583965e74254799f13ae.tar.bz2 |
ConstantRange: add query for isAllPositive (#97420)
ConstantRange has queries for isAllNegative and isAllNonNegative, but
misses a query for isAllPositive. Add this function.
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r-- | llvm/unittests/IR/ConstantRangeTest.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp index 392c41f..0181e2c 100644 --- a/llvm/unittests/IR/ConstantRangeTest.cpp +++ b/llvm/unittests/IR/ConstantRangeTest.cpp @@ -2398,23 +2398,31 @@ TEST_F(ConstantRangeTest, Negative) { // they are also covered by the exhaustive test below. EXPECT_TRUE(Empty.isAllNegative()); EXPECT_TRUE(Empty.isAllNonNegative()); + EXPECT_TRUE(Empty.isAllPositive()); EXPECT_FALSE(Full.isAllNegative()); EXPECT_FALSE(Full.isAllNonNegative()); + EXPECT_FALSE(Full.isAllPositive()); EnumerateInterestingConstantRanges([](const ConstantRange &CR) { bool AllNegative = true; bool AllNonNegative = true; + bool AllPositive = true; ForeachNumInConstantRange(CR, [&](const APInt &N) { if (!N.isNegative()) AllNegative = false; if (!N.isNonNegative()) AllNonNegative = false; + if (!N.isStrictlyPositive()) + AllPositive = false; }); - assert((CR.isEmptySet() || !AllNegative || !AllNonNegative) && - "Only empty set can be both all negative and all non-negative"); + assert( + (CR.isEmptySet() || !AllNegative || !AllNonNegative || !AllPositive) && + "Only empty set can be all negative, all non-negative, and all " + "positive"); EXPECT_EQ(AllNegative, CR.isAllNegative()); EXPECT_EQ(AllNonNegative, CR.isAllNonNegative()); + EXPECT_EQ(AllPositive, CR.isAllPositive()); }); } |