[DemandedBits] Reduce number of duplicated DenseMap lookups.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 21 Jul 2016 13:37:55 +0000 (13:37 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 21 Jul 2016 13:37:55 +0000 (13:37 +0000)
No functionality change intended.

llvm-svn: 276278

llvm/lib/Analysis/DemandedBits.cpp

index a3f8b7f..ee9f2c7 100644 (file)
@@ -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(Instruction *I) {
   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()));
 }