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/lib/IR/ConstantRange.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/lib/IR/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 10 |
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()); |