[DemandedBits] Reduce number of duplicated DenseMap lookups.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276278 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2016-07-21 13:37:55 +00:00
parent 1a324fd49a
commit ffecbde8b3

View File

@ -280,10 +280,8 @@ void DemandedBits::performAnalysis() {
// add their operands to the work list (for integer values operands, mark // add their operands to the work list (for integer values operands, mark
// all bits as live). // all bits as live).
if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) { if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) {
if (!AliveBits.count(&I)) { if (AliveBits.try_emplace(&I, IT->getBitWidth(), 0).second)
AliveBits[&I] = APInt(IT->getBitWidth(), 0);
Worklist.push_back(&I); Worklist.push_back(&I);
}
continue; continue;
} }
@ -363,8 +361,9 @@ APInt DemandedBits::getDemandedBits(Instruction *I) {
performAnalysis(); performAnalysis();
const DataLayout &DL = I->getParent()->getModule()->getDataLayout(); const DataLayout &DL = I->getParent()->getModule()->getDataLayout();
if (AliveBits.count(I)) auto Found = AliveBits.find(I);
return AliveBits[I]; if (Found != AliveBits.end())
return Found->second;
return APInt::getAllOnesValue(DL.getTypeSizeInBits(I->getType())); return APInt::getAllOnesValue(DL.getTypeSizeInBits(I->getType()));
} }