diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h index cc79870229873..b85e11942a320 100644 --- a/llvm/include/llvm/Analysis/SparsePropagation.h +++ b/llvm/include/llvm/Analysis/SparsePropagation.h @@ -244,13 +244,13 @@ SparseSolver::getValueState(LatticeKey Key) { template void SparseSolver::UpdateState(LatticeKey Key, LatticeVal LV) { - auto I = ValueState.find(Key); - if (I != ValueState.end() && I->second == LV) + auto [I, Inserted] = ValueState.try_emplace(Key); + if (!Inserted && I->second == LV) return; // No change. // Update the state of the given LatticeKey and add its corresponding LLVM // value to the work list. - ValueState[Key] = std::move(LV); + I->second = std::move(LV); if (Value *V = KeyInfo::getValueFromLatticeKey(Key)) ValueWorkList.push_back(V); }