]> granicus.if.org Git - llvm/commitdiff
[ConstantRange] Replace getMaxValue+zext with getLowBitsSet. Replace zero-init+setBit...
authorCraig Topper <craig.topper@gmail.com>
Sat, 29 Apr 2017 17:46:13 +0000 (17:46 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 29 Apr 2017 17:46:13 +0000 (17:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301752 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/ConstantRange.cpp

index 754844e371a8872e87d883b09083bc26b70727ca..8b595a69ad37a0b21cacae16cc302b8951a4960a 100644 (file)
@@ -569,9 +569,8 @@ ConstantRange ConstantRange::truncate(uint32_t DstTySize) const {
   if (isFullSet())
     return ConstantRange(DstTySize, /*isFullSet=*/true);
 
-  APInt MaxValue = APInt::getMaxValue(DstTySize).zext(getBitWidth());
-  APInt MaxBitValue(getBitWidth(), 0);
-  MaxBitValue.setBit(DstTySize);
+  APInt MaxValue = APInt::getLowBitsSet(getBitWidth(), DstTySize);
+  APInt MaxBitValue = APInt::getOneBitSet(getBitWidth(), DstTySize);
 
   APInt LowerDiv(Lower), UpperDiv(Upper);
   ConstantRange Union(DstTySize, /*isFullSet=*/false);