Make the apint construction more effective.
authorZhou Sheng <zhousheng00@gmail.com>
Fri, 13 Apr 2007 05:57:32 +0000 (05:57 +0000)
committerZhou Sheng <zhousheng00@gmail.com>
Fri, 13 Apr 2007 05:57:32 +0000 (05:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35960 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/ConstantRange.cpp

index 79a85b80d7ea3b1cc7f5184f570cc8058222e117..71796493301bb53e048c45eafe17796e491f4481 100644 (file)
@@ -108,7 +108,7 @@ APInt ConstantRange::getUnsignedMin() const {
 /// ConstantRange.
 ///
 APInt ConstantRange::getSignedMax() const {
-  APInt SignedMax = APInt::getSignedMaxValue(getBitWidth());
+  APInt SignedMax(APInt::getSignedMaxValue(getBitWidth()));
   if (!isWrappedSet()) {
     if (getLower().slt(getUpper() - 1))
       return getUpper() - 1;
@@ -130,7 +130,7 @@ APInt ConstantRange::getSignedMax() const {
 /// ConstantRange.
 ///
 APInt ConstantRange::getSignedMin() const {
-  APInt SignedMin = APInt::getSignedMinValue(getBitWidth());
+  APInt SignedMin(APInt::getSignedMinValue(getBitWidth()));
   if (!isWrappedSet()) {
     if (getLower().slt(getUpper() - 1))
       return getLower();
@@ -370,7 +370,7 @@ ConstantRange ConstantRange::signExtend(uint32_t DstTySize) const {
 ConstantRange ConstantRange::truncate(uint32_t DstTySize) const {
   unsigned SrcTySize = getBitWidth();
   assert(SrcTySize > DstTySize && "Not a value truncation");
-  APInt Size = APInt::getMaxValue(DstTySize).zext(SrcTySize);
+  APInt Size(APInt::getLowBitsSet(SrcTySize, DstTySize));
   if (isFullSet() || getSetSize().ugt(Size))
     return ConstantRange(DstTySize);