]> granicus.if.org Git - llvm/commitdiff
[ConstantRange] Use APInt::operator-= to remove temporary APInts.
authorCraig Topper <craig.topper@gmail.com>
Sat, 29 Apr 2017 17:46:11 +0000 (17:46 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 29 Apr 2017 17:46:11 +0000 (17:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301751 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/ConstantRange.cpp

index fd678c2825614da052b88abe9ea5ebdbd87719ad..754844e371a8872e87d883b09083bc26b70727ca 100644 (file)
@@ -597,7 +597,7 @@ ConstantRange ConstantRange::truncate(uint32_t DstTySize) const {
   if (LowerDiv.uge(MaxValue)) {
     APInt Div(getBitWidth(), 0);
     APInt::udivrem(LowerDiv, MaxBitValue, Div, LowerDiv);
-    UpperDiv = UpperDiv - MaxBitValue * Div;
+    UpperDiv -= MaxBitValue * Div;
   }
 
   if (UpperDiv.ule(MaxValue))
@@ -605,10 +605,10 @@ ConstantRange ConstantRange::truncate(uint32_t DstTySize) const {
                          UpperDiv.trunc(DstTySize)).unionWith(Union);
 
   // The truncated value wraps around. Check if we can do better than fullset.
-  APInt UpperModulo = UpperDiv - MaxBitValue;
-  if (UpperModulo.ult(LowerDiv))
+  UpperDiv -= MaxBitValue;
+  if (UpperDiv.ult(LowerDiv))
     return ConstantRange(LowerDiv.trunc(DstTySize),
-                         UpperModulo.trunc(DstTySize)).unionWith(Union);
+                         UpperDiv.trunc(DstTySize)).unionWith(Union);
 
   return ConstantRange(DstTySize, /*isFullSet=*/true);
 }