From: Sanjoy Das Date: Tue, 27 Oct 2015 01:36:06 +0000 (+0000) Subject: [ValueTracking] Don't special case wrapped ConstantRanges; NFCI X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;ds=sidebyside;h=80fb6a4137ba13542a3547e35e2e4a5404ed6ba2;hp=9b0157716902f900919d4d1c7f211f9ae36cd5b1;p=oota-llvm.git [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251380 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 1171149180b..e25087e6911 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -380,9 +380,7 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges, ConstantInt *Upper = mdconst::extract(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); }