summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/ConstantRange.cpp
diff options
context:
space:
mode:
authorMarcello Maggioni <hayarms@gmail.com>2019-04-07 06:12:44 +0000
committerMarcello Maggioni <hayarms@gmail.com>2019-04-07 06:12:44 +0000
commit30eb5758112a7f972d4ffea4ed0aa5f1c2732b40 (patch)
treee4f923b30450506d856638fc42247906e4f7388e /llvm/lib/IR/ConstantRange.cpp
parent545ed223a65513475203f81f267bf1656b8f4e04 (diff)
downloadbcm5719-llvm-30eb5758112a7f972d4ffea4ed0aa5f1c2732b40.tar.gz
bcm5719-llvm-30eb5758112a7f972d4ffea4ed0aa5f1c2732b40.zip
[ConstantRange] Shl considers full-set shifting to last bit position.
if we do SHL of two 16-bit ranges like [0, 30000) with [1,2) we get "full-set" instead of what I would have expected [0, 60000) which is still in the 16-bit unsigned range. This patch changes the SHL algorithm to allow getting a usable range even in this case. Differential Revision: https://reviews.llvm.org/D57983 llvm-svn: 357854
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index eda31f73473..f07ec9d5a3f 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -1006,8 +1006,12 @@ ConstantRange::shl(const ConstantRange &Other) const {
APInt max = getUnsignedMax();
APInt Other_umax = Other.getUnsignedMax();
+ // If we are shifting by maximum amount of
+ // zero return return the original range.
+ if (Other_umax.isNullValue())
+ return *this;
// there's overflow!
- if (Other_umax.uge(max.countLeadingZeros()))
+ if (Other_umax.ugt(max.countLeadingZeros()))
return getFull();
// FIXME: implement the other tricky cases
OpenPOWER on IntegriCloud