diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2021-04-10 19:37:59 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2021-04-10 19:38:55 +0300 |
commit | e8c7f43e2c2c6f3581ec1c6489ec21ad9f98958a (patch) | |
tree | 85a7b7ec57c83340778733ffba90c16d38ed80f4 /llvm/lib/IR/ConstantRange.cpp | |
parent | 7b12c8c59da6f028db1aad948d116d09309a91f5 (diff) | |
download | llvm-e8c7f43e2c2c6f3581ec1c6489ec21ad9f98958a.zip llvm-e8c7f43e2c2c6f3581ec1c6489ec21ad9f98958a.tar.gz llvm-e8c7f43e2c2c6f3581ec1c6489ec21ad9f98958a.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.cpp | 5 |
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(); |