diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-17 15:43:59 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-17 15:43:59 +0000 |
commit | 5d2fada44ce77c6db15173a8107bf253c2293170 (patch) | |
tree | ec39c9ea7ca404bbce20518541d721c0eff314df /lib/Support | |
parent | f30135c519a983513b1a9cb4c96409cda4c5b39e (diff) | |
download | external_llvm-5d2fada44ce77c6db15173a8107bf253c2293170.zip external_llvm-5d2fada44ce77c6db15173a8107bf253c2293170.tar.gz external_llvm-5d2fada44ce77c6db15173a8107bf253c2293170.tar.bz2 |
simplify getSetSize() per Duncan's comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/ConstantRange.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index 221ca94..b7b38e4 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -146,14 +146,13 @@ APInt ConstantRange::getSetSize() const { if (isEmptySet()) return APInt(getBitWidth()+1, 0); - if (isFullSet()) - return APInt::getMaxValue(getBitWidth()).zext(getBitWidth()+1) + 1; - - if (isWrappedSet()) { - APInt Result = Upper + (APInt::getMaxValue(getBitWidth()) - Lower + 1); - return Result.zext(getBitWidth()+1); + if (isFullSet()) { + APInt Size(getBitWidth()+1, 0); + Size.setBit(getBitWidth()); + return Size; } + // This is also correct for wrapped sets. return (Upper - Lower).zext(getBitWidth()+1); } |