summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-10-27 01:36:06 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-10-27 01:36:06 +0000
commit63d2b7796138144cc6e3a8fb98f9c4b10606ea12 (patch)
treee83503a213c1a723c2526aee48a368699261f9e8 /llvm/lib/Analysis
parent171d6fa35db2ad0d61a5947d4752f431e7baa042 (diff)
downloadbcm5719-llvm-63d2b7796138144cc6e3a8fb98f9c4b10606ea12.tar.gz
bcm5719-llvm-63d2b7796138144cc6e3a8fb98f9c4b10606ea12.zip
[ValueTracking] Don't special case wrapped ConstantRanges; NFCI
Use `getUnsignedMax` directly instead of special casing a wrapped ConstantRange. The previous code would have been "buggy" (and this would have been a semantic change) if LLVM allowed !range metadata to denote full ranges. E.g. in %val = load i1, i1* %ptr, !range !{i1 1, i1 1} ;; == full set ValueTracking would conclude that the high bit (IOW the only bit) in %val was zero. Since !range metadata does not allow empty or full ranges, this change is just a minor stylistic improvement. llvm-svn: 251380
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1171149180b..e25087e6911 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -380,9 +380,7 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
ConstantInt *Upper =
mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 1));
ConstantRange Range(Lower->getValue(), Upper->getValue());
- if (Range.isWrappedSet())
- MinLeadingZeros = 0; // -1 has no zeros
- unsigned LeadingZeros = (Upper->getValue() - 1).countLeadingZeros();
+ unsigned LeadingZeros = Range.getUnsignedMax().countLeadingZeros();
MinLeadingZeros = std::min(LeadingZeros, MinLeadingZeros);
}
OpenPOWER on IntegriCloud