OSDN Git Service

simplify getSetSize() per Duncan's comments
authorNuno Lopes <nunoplopes@sapo.pt>
Tue, 17 Jul 2012 15:43:59 +0000 (15:43 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Tue, 17 Jul 2012 15:43:59 +0000 (15:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160368 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/ConstantRange.cpp

index 221ca94..b7b38e4 100644 (file)
@@ -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);
 }