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

Benjamin Kramer benny.kra at googlemail.com
Thu Nov 24 09:24:33 PST 2011


Author: d0k
Date: Thu Nov 24 11:24:33 2011
New Revision: 145122

URL: http://llvm.org/viewvc/llvm-project?rev=145122&view=rev
Log:
Make ConstantRange::truncate a bit more efficient.

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=145122&r1=145121&r2=145122&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ConstantRange.cpp (original)
+++ llvm/trunk/lib/Support/ConstantRange.cpp Thu Nov 24 11:24:33 2011
@@ -466,10 +466,8 @@
 /// correspond to the possible range of values as if the source range had been
 /// truncated to the specified type.
 ConstantRange ConstantRange::truncate(uint32_t DstTySize) const {
-  unsigned SrcTySize = getBitWidth();
-  assert(SrcTySize > DstTySize && "Not a value truncation");
-  APInt Size(APInt::getLowBitsSet(SrcTySize, DstTySize));
-  if (isFullSet() || getSetSize().ugt(Size))
+  assert(getBitWidth() > DstTySize && "Not a value truncation");
+  if (isFullSet() || getSetSize().getActiveBits() > DstTySize)
     return ConstantRange(DstTySize, /*isFullSet=*/true);
 
   return ConstantRange(Lower.trunc(DstTySize), Upper.trunc(DstTySize));





More information about the llvm-commits mailing list