Ensure KnownBits passed when calculating from range md has right size (#132985)
KnownBits passed to computeKnownBitsFromRangeMetadata must have the same bit width as the range metadata bit width. Otherwise the calculated results will be incorrect. --------- Signed-off-by: John Lu <John.Lu@amd.com>
This commit is contained in:
parent
dcc2182bce
commit
6a46c6c865
@ -430,6 +430,10 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
|
||||
ConstantInt *Upper =
|
||||
mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 1));
|
||||
ConstantRange Range(Lower->getValue(), Upper->getValue());
|
||||
// BitWidth must equal the Ranges BitWidth for the correct number of high
|
||||
// bits to be set.
|
||||
assert(BitWidth == Range.getBitWidth() &&
|
||||
"Known bit width must match range bit width!");
|
||||
|
||||
// The first CommonPrefixBits of all values in Range are equal.
|
||||
unsigned CommonPrefixBits =
|
||||
|
||||
@ -9176,6 +9176,12 @@ SDValue SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
|
||||
"Cannot use an ext load to change the number of vector elements!");
|
||||
}
|
||||
|
||||
assert((!MMO->getRanges() ||
|
||||
(mdconst::extract<ConstantInt>(MMO->getRanges()->getOperand(0))
|
||||
->getBitWidth() == MemVT.getScalarSizeInBits() &&
|
||||
MemVT.isInteger())) &&
|
||||
"Range metadata and load type must match!");
|
||||
|
||||
bool Indexed = AM != ISD::UNINDEXED;
|
||||
assert((Indexed || Offset.isUndef()) && "Unindexed load with an offset!");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user