aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantRange.cpp
diff options
context:
space:
mode:
authorRamkumar Ramachandra <ramkumar.ramachandra@codasip.com>2024-07-03 10:50:22 +0100
committerGitHub <noreply@github.com>2024-07-03 10:50:22 +0100
commitedbbc832a5308e4f6943583965e74254799f13ae (patch)
tree4f1ab3ab72bec44382004798b64b923e51236002 /llvm/lib/IR/ConstantRange.cpp
parent5a1a46722948b79803826f1b11877ffcf102c094 (diff)
downloadllvm-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/lib/IR/ConstantRange.cpp')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 1904170..50de975 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -440,6 +440,16 @@ bool ConstantRange::isAllNonNegative() const {
return !isSignWrappedSet() && Lower.isNonNegative();
}
+bool ConstantRange::isAllPositive() const {
+ // Empty set is all positive, full set is not.
+ if (isEmptySet())
+ return true;
+ if (isFullSet())
+ return false;
+
+ return !isSignWrappedSet() && Lower.isStrictlyPositive();
+}
+
APInt ConstantRange::getUnsignedMax() const {
if (isFullSet() || isUpperWrapped())
return APInt::getMaxValue(getBitWidth());