aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantRange.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2021-04-10 17:58:47 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2021-04-10 19:09:52 +0300
commit17cf2c94230bc107e7294ef84fad3b47f4cd1b73 (patch)
tree85a7b7ec57c83340778733ffba90c16d38ed80f4 /llvm/lib/IR/ConstantRange.cpp
parent0c184154969c020db416bd7066af80ffd2a27ac4 (diff)
downloadllvm-17cf2c94230bc107e7294ef84fad3b47f4cd1b73.zip
llvm-17cf2c94230bc107e7294ef84fad3b47f4cd1b73.tar.gz
llvm-17cf2c94230bc107e7294ef84fad3b47f4cd1b73.tar.bz2
[NFC][ConstantRange] Add 'icmp' helper method
"Does the predicate hold between two ranges?" Not very surprisingly, some places were already doing this check, without explicitly naming the algorithm, cleanup them all.
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 4dbe1a1..b38599f 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -181,6 +181,11 @@ bool ConstantRange::getEquivalentICmp(CmpInst::Predicate &Pred,
return Success;
}
+bool ConstantRange::icmp(CmpInst::Predicate Pred,
+ const ConstantRange &Other) const {
+ return makeSatisfyingICmpRegion(Pred, Other).contains(*this);
+}
+
/// Exact mul nuw region for single element RHS.
static ConstantRange makeExactMulNUWRegion(const APInt &V) {
unsigned BitWidth = V.getBitWidth();