[llvm] r301751 - [ConstantRange] Use APInt::operator-= to remove temporary APInts.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 29 10:46:11 PDT 2017


Author: ctopper
Date: Sat Apr 29 12:46:11 2017
New Revision: 301751

URL: http://llvm.org/viewvc/llvm-project?rev=301751&view=rev
Log:
[ConstantRange] Use APInt::operator-= to remove temporary APInts.

Modified:
    llvm/trunk/lib/IR/ConstantRange.cpp

Modified: llvm/trunk/lib/IR/ConstantRange.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantRange.cpp?rev=301751&r1=301750&r2=301751&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantRange.cpp (original)
+++ llvm/trunk/lib/IR/ConstantRange.cpp Sat Apr 29 12:46:11 2017
@@ -597,7 +597,7 @@ ConstantRange ConstantRange::truncate(ui
   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(ui
                          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);
 }




More information about the llvm-commits mailing list