From 79b7666f02af974052e2d0340077ed9fd8259dbc Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 9 May 2017 07:04:02 +0000 Subject: [PATCH] [ConstantRange] Combine the two adds max+1 in lshr into a single addition. llvm-svn: 302509 --- llvm/lib/IR/ConstantRange.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index a7c857a..6801ed4 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -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 { -- 2.7.4