[llvm-commits] [llvm] r86133 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Benjamin Kramer
benny.kra at googlemail.com
Thu Nov 5 06:33:28 PST 2009
Author: d0k
Date: Thu Nov 5 08:33:27 2009
New Revision: 86133
URL: http://llvm.org/viewvc/llvm-project?rev=86133&view=rev
Log:
Do map insert+find in one step. TODO -= 2.
Modified:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=86133&r1=86132&r2=86133&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Nov 5 08:33:27 2009
@@ -370,13 +370,13 @@
/// by properly seeding constants etc.
LatticeVal &getValueState(Value *V) {
assert(!isa<StructType>(V->getType()) && "Should use getStructValueState");
-
- // TODO: Change to do insert+find in one operation.
- DenseMap<Value*, LatticeVal>::iterator I = ValueState.find(V);
- if (I != ValueState.end())
- return I->second; // Common case, already in the map.
- LatticeVal &LV = ValueState[V];
+ std::pair<DenseMap<Value*, LatticeVal>::iterator, bool> I =
+ ValueState.insert(std::make_pair(V, LatticeVal()));
+ LatticeVal &LV = I.first->second;
+
+ if (!I.second)
+ return LV; // Common case, already in the map.
if (Constant *C = dyn_cast<Constant>(V)) {
// Undef values remain undefined.
@@ -395,15 +395,15 @@
assert(isa<StructType>(V->getType()) && "Should use getValueState");
assert(i < cast<StructType>(V->getType())->getNumElements() &&
"Invalid element #");
-
- // TODO: Change to do insert+find in one operation.
- DenseMap<std::pair<Value*, unsigned>, LatticeVal>::iterator
- I = StructValueState.find(std::make_pair(V, i));
- if (I != StructValueState.end())
- return I->second; // Common case, already in the map.
-
- LatticeVal &LV = StructValueState[std::make_pair(V, i)];
-
+
+ std::pair<DenseMap<std::pair<Value*, unsigned>, LatticeVal>::iterator,
+ bool> I = StructValueState.insert(
+ std::make_pair(std::make_pair(V, i), LatticeVal()));
+ LatticeVal &LV = I.first->second;
+
+ if (!I.second)
+ return LV; // Common case, already in the map.
+
if (Constant *C = dyn_cast<Constant>(V)) {
if (isa<UndefValue>(C))
; // Undef values remain undefined.
More information about the llvm-commits
mailing list