diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-11-07 21:21:41 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-11-07 21:22:45 +0100 |
commit | cf71a5ea8f95be423ebd381d21d0f9a05edc5018 (patch) | |
tree | 5026d23f31b8465d0bf1971b80bfb485c34d84cb /llvm/lib/IR/ConstantRange.cpp | |
parent | d09a21a0b378675c7f69628ce7a9cd0d54dec1da (diff) | |
download | llvm-cf71a5ea8f95be423ebd381d21d0f9a05edc5018.zip llvm-cf71a5ea8f95be423ebd381d21d0f9a05edc5018.tar.gz llvm-cf71a5ea8f95be423ebd381d21d0f9a05edc5018.tar.bz2 |
[ConstantRange] Support zero size in isSizeLargerThan()
From an API perspective, it does not make a lot of sense that 0
is not a valid argument to this function. Add the exact check needed
to support it.
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index b01f5cf..bbb07bf 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -381,11 +381,10 @@ ConstantRange::isSizeStrictlySmallerThan(const ConstantRange &Other) const { bool ConstantRange::isSizeLargerThan(uint64_t MaxSize) const { - assert(MaxSize && "MaxSize can't be 0."); // If this a full set, we need special handling to avoid needing an extra bit // to represent the size. if (isFullSet()) - return APInt::getMaxValue(getBitWidth()).ugt(MaxSize - 1); + return MaxSize == 0 || APInt::getMaxValue(getBitWidth()).ugt(MaxSize - 1); return (Upper - Lower).ugt(MaxSize); } |