diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-16 18:08:12 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-16 18:08:12 +0000 |
commit | 99504c577cc58bbc4979216dfaa360bec27e99c7 (patch) | |
tree | 8ac7902a4636fd6366d1020e0b61abdb6d6d4e83 /llvm/lib/Support | |
parent | 10e8207c9eedf02013899bb3eb4ce535d51512a5 (diff) | |
download | bcm5719-llvm-99504c577cc58bbc4979216dfaa360bec27e99c7.tar.gz bcm5719-llvm-99504c577cc58bbc4979216dfaa360bec27e99c7.zip |
make ConstantRange::getSetSize() properly compute the size of wrapped and full sets.
Make it always return APInts with the same bitwidth for the same ConstantRange bitwidth to simply clients
llvm-svn: 160294
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/ConstantRange.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp index 91d086b6890..b83dcccca67 100644 --- a/llvm/lib/Support/ConstantRange.cpp +++ b/llvm/lib/Support/ConstantRange.cpp @@ -143,16 +143,18 @@ bool ConstantRange::isSignWrappedSet() const { /// getSetSize - Return the number of elements in this set. /// APInt ConstantRange::getSetSize() const { - if (isEmptySet()) - return APInt(getBitWidth(), 0); - if (getBitWidth() == 1) { - if (Lower != Upper) // One of T or F in the set... - return APInt(2, 1); - return APInt(2, 2); // Must be full set... + 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); } - // Simply subtract the bounds... - return Upper - Lower; + return (Upper - Lower).zext(getBitWidth()+1); } /// getUnsignedMax - Return the largest unsigned value contained in the |