summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-11-24 17:24:33 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-11-24 17:24:33 +0000
commit6709e05012cb91a4edf613bcf6c81c5f51f8ac34 (patch)
treeeaadfb8e299296330bbfbefd5632f7e33a68f36f /llvm/lib
parent651db37352b22cd285b1caa1898b657d0556b169 (diff)
downloadbcm5719-llvm-6709e05012cb91a4edf613bcf6c81c5f51f8ac34.tar.gz
bcm5719-llvm-6709e05012cb91a4edf613bcf6c81c5f51f8ac34.zip
Make ConstantRange::truncate a bit more efficient.
llvm-svn: 145122
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/ConstantRange.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp
index c29cb53fb9c..57434795070 100644
--- a/llvm/lib/Support/ConstantRange.cpp
+++ b/llvm/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));
OpenPOWER on IntegriCloud