[llvm] r276278 - [DemandedBits] Reduce number of duplicated DenseMap lookups.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 06:37:56 PDT 2016
Author: d0k
Date: Thu Jul 21 08:37:55 2016
New Revision: 276278
URL: http://llvm.org/viewvc/llvm-project?rev=276278&view=rev
Log:
[DemandedBits] Reduce number of duplicated DenseMap lookups.
No functionality change intended.
Modified:
llvm/trunk/lib/Analysis/DemandedBits.cpp
Modified: llvm/trunk/lib/Analysis/DemandedBits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DemandedBits.cpp?rev=276278&r1=276277&r2=276278&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DemandedBits.cpp (original)
+++ llvm/trunk/lib/Analysis/DemandedBits.cpp Thu Jul 21 08:37:55 2016
@@ -280,10 +280,8 @@ void DemandedBits::performAnalysis() {
// add their operands to the work list (for integer values operands, mark
// all bits as live).
if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) {
- if (!AliveBits.count(&I)) {
- AliveBits[&I] = APInt(IT->getBitWidth(), 0);
+ if (AliveBits.try_emplace(&I, IT->getBitWidth(), 0).second)
Worklist.push_back(&I);
- }
continue;
}
@@ -363,8 +361,9 @@ APInt DemandedBits::getDemandedBits(Inst
performAnalysis();
const DataLayout &DL = I->getParent()->getModule()->getDataLayout();
- if (AliveBits.count(I))
- return AliveBits[I];
+ auto Found = AliveBits.find(I);
+ if (Found != AliveBits.end())
+ return Found->second;
return APInt::getAllOnesValue(DL.getTypeSizeInBits(I->getType()));
}
More information about the llvm-commits
mailing list