Skip to content

Commit d68da5a

Browse files
committed
Use Range.getBitWidth()
Signed-off-by: John Lu <[email protected]>
1 parent f2e682b commit d68da5a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,14 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
429429
ConstantInt *Upper =
430430
mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 1));
431431
ConstantRange Range(Lower->getValue(), Upper->getValue());
432+
// BitWidth must equal the Ranges BitWidth for the correct number of high
433+
// bits to be set.
434+
assert(BitWidth == Range.getBitWidth() &&
435+
"Known bit width must match range bit width!");
432436

433437
// The first CommonPrefixBits of all values in Range are equal.
434438
unsigned CommonPrefixBits =
435439
(Range.getUnsignedMax() ^ Range.getUnsignedMin()).countl_zero();
436-
// BitWidth must equal the Ranges BitWidth for the correct number of high
437-
// bits to be set.
438-
assert(BitWidth == Lower->getBitWidth() &&
439-
"Known bit width must match range bit width!");
440440
APInt Mask = APInt::getHighBitsSet(BitWidth, CommonPrefixBits);
441441
APInt UnsignedMax = Range.getUnsignedMax().zextOrTrunc(BitWidth);
442442
Known.One &= UnsignedMax & Mask;

0 commit comments

Comments
 (0)