[ConstantRange] Combine the two adds max+1 in lshr into a single addition.
authorCraig Topper <craig.topper@gmail.com>
Tue, 9 May 2017 07:04:02 +0000 (07:04 +0000)
committerCraig Topper <craig.topper@gmail.com>
Tue, 9 May 2017 07:04:02 +0000 (07:04 +0000)
llvm-svn: 302509

llvm/lib/IR/ConstantRange.cpp

index a7c857a..6801ed4 100644 (file)
@@ -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 {