Make ConstantRange::truncate a bit more efficient.

llvm-svn: 145122
This commit is contained in:
Benjamin Kramer 2011-11-24 17:24:33 +00:00
parent 651db37352
commit 6709e05012
1 changed files with 2 additions and 4 deletions

View File

@ -466,10 +466,8 @@ ConstantRange ConstantRange::signExtend(uint32_t DstTySize) const {
/// 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));