diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-11-24 17:24:33 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-11-24 17:24:33 +0000 |
commit | b3ff49e923225d0f7242ef5ac554bdef34c1b216 (patch) | |
tree | 90d8573f1446abf6463b35c8ecf0970b907163ac /lib/Support/ConstantRange.cpp | |
parent | 9d399b1fc2f7dfad72f5ff3328983acb805eaf10 (diff) |
Make ConstantRange::truncate a bit more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145122 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/ConstantRange.cpp')
-rw-r--r-- | lib/Support/ConstantRange.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index c29cb53fb9..5743479507 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -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)); |