[llvm-commits] [llvm] r160368 - /llvm/trunk/lib/Support/ConstantRange.cpp

Nuno Lopes nunoplopes at sapo.pt
Tue Jul 17 08:43:59 PDT 2012


Author: nlopes
Date: Tue Jul 17 10:43:59 2012
New Revision: 160368

URL: http://llvm.org/viewvc/llvm-project?rev=160368&view=rev
Log:
simplify getSetSize() per Duncan's comments

Modified:
    llvm/trunk/lib/Support/ConstantRange.cpp

Modified: llvm/trunk/lib/Support/ConstantRange.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=160368&r1=160367&r2=160368&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ConstantRange.cpp (original)
+++ llvm/trunk/lib/Support/ConstantRange.cpp Tue Jul 17 10:43:59 2012
@@ -146,14 +146,13 @@
   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);
 }
 





More information about the llvm-commits mailing list