mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[ValueTracking] Convert computeKnownBitsFromRangeMetadata to use KnownBits struct.
llvm-svn: 301626
This commit is contained in:
parent
1afc99a07a
commit
d9d5a16d7c
@ -60,7 +60,7 @@ template <typename T> class ArrayRef;
|
||||
/// \p KnownZero the set of bits that are known to be zero
|
||||
/// \p KnownOne the set of bits that are known to be one
|
||||
void computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
|
||||
APInt &KnownZero, APInt &KnownOne);
|
||||
KnownBits &Known);
|
||||
/// Return true if LHS and RHS have no common bits set.
|
||||
bool haveNoCommonBitsSet(const Value *LHS, const Value *RHS,
|
||||
const DataLayout &DL,
|
||||
|
@ -367,14 +367,13 @@ static void computeKnownBitsMul(const Value *Op0, const Value *Op1, bool NSW,
|
||||
}
|
||||
|
||||
void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
|
||||
APInt &KnownZero,
|
||||
APInt &KnownOne) {
|
||||
unsigned BitWidth = KnownZero.getBitWidth();
|
||||
KnownBits &Known) {
|
||||
unsigned BitWidth = Known.getBitWidth();
|
||||
unsigned NumRanges = Ranges.getNumOperands() / 2;
|
||||
assert(NumRanges >= 1);
|
||||
|
||||
KnownZero.setAllBits();
|
||||
KnownOne.setAllBits();
|
||||
Known.Zero.setAllBits();
|
||||
Known.One.setAllBits();
|
||||
|
||||
for (unsigned i = 0; i < NumRanges; ++i) {
|
||||
ConstantInt *Lower =
|
||||
@ -388,8 +387,8 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
|
||||
(Range.getUnsignedMax() ^ Range.getUnsignedMin()).countLeadingZeros();
|
||||
|
||||
APInt Mask = APInt::getHighBitsSet(BitWidth, CommonPrefixBits);
|
||||
KnownOne &= Range.getUnsignedMax() & Mask;
|
||||
KnownZero &= ~Range.getUnsignedMax() & Mask;
|
||||
Known.One &= Range.getUnsignedMax() & Mask;
|
||||
Known.Zero &= ~Range.getUnsignedMax() & Mask;
|
||||
}
|
||||
}
|
||||
|
||||
@ -902,7 +901,7 @@ static void computeKnownBitsFromOperator(const Operator *I, KnownBits &Known,
|
||||
default: break;
|
||||
case Instruction::Load:
|
||||
if (MDNode *MD = cast<LoadInst>(I)->getMetadata(LLVMContext::MD_range))
|
||||
computeKnownBitsFromRangeMetadata(*MD, Known.Zero, Known.One);
|
||||
computeKnownBitsFromRangeMetadata(*MD, Known);
|
||||
break;
|
||||
case Instruction::And: {
|
||||
// If either the LHS or the RHS are Zero, the result is zero.
|
||||
@ -1384,7 +1383,7 @@ static void computeKnownBitsFromOperator(const Operator *I, KnownBits &Known,
|
||||
// and then intersect with known bits based on other properties of the
|
||||
// function.
|
||||
if (MDNode *MD = cast<Instruction>(I)->getMetadata(LLVMContext::MD_range))
|
||||
computeKnownBitsFromRangeMetadata(*MD, Known.Zero, Known.One);
|
||||
computeKnownBitsFromRangeMetadata(*MD, Known);
|
||||
if (const Value *RV = ImmutableCallSite(I).getReturnedArgOperand()) {
|
||||
computeKnownBits(RV, Known2, Depth + 1, Q);
|
||||
Known.Zero |= Known2.Zero;
|
||||
|
@ -2395,7 +2395,7 @@ void SelectionDAG::computeKnownBits(SDValue Op, KnownBits &Known,
|
||||
Known.Zero.setBitsFrom(MemBits);
|
||||
} else if (const MDNode *Ranges = LD->getRanges()) {
|
||||
if (LD->getExtensionType() == ISD::NON_EXTLOAD)
|
||||
computeKnownBitsFromRangeMetadata(*Ranges, Known.Zero, Known.One);
|
||||
computeKnownBitsFromRangeMetadata(*Ranges, Known);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user