[llvm] r302509 - [ConstantRange] Combine the two adds max+1 in lshr into a single addition.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 00:04:02 PDT 2017


Author: ctopper
Date: Tue May  9 02:04:02 2017
New Revision: 302509

URL: http://llvm.org/viewvc/llvm-project?rev=302509&view=rev
Log:
[ConstantRange] Combine the two adds max+1 in lshr into a single addition.

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=302509&r1=302508&r2=302509&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantRange.cpp (original)
+++ llvm/trunk/lib/IR/ConstantRange.cpp Tue May  9 02:04:02 2017
@@ -908,13 +908,13 @@ ConstantRange
 ConstantRange::lshr(const ConstantRange &Other) const {
   if (isEmptySet() || Other.isEmptySet())
     return ConstantRange(getBitWidth(), /*isFullSet=*/false);
-  
-  APInt max = getUnsignedMax().lshr(Other.getUnsignedMin());
+
+  APInt max = getUnsignedMax().lshr(Other.getUnsignedMin()) + 1;
   APInt min = getUnsignedMin().lshr(Other.getUnsignedMax());
-  if (min == max + 1)
+  if (min == max)
     return ConstantRange(getBitWidth(), /*isFullSet=*/true);
 
-  return ConstantRange(std::move(min), std::move(max) + 1);
+  return ConstantRange(std::move(min), std::move(max));
 }
 
 ConstantRange ConstantRange::inverse() const {




More information about the llvm-commits mailing list