[LV] Prefer DenseMap::lookup over find (NFC) (#141809)
Apart from the stylistic improvement, lookup has the nice property of
returning a default-constructed object on failure-to-find, while find
returns the end iterator, which cannot be dereferenced.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 05fd87e..fc8ebeb 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2548,9 +2548,9 @@
return C->getValue();
if (auto *U = dyn_cast<SCEVUnknown>(Step))
return U->getValue();
- auto I = ExpandedSCEVs.find(Step);
- assert(I != ExpandedSCEVs.end() && "SCEV must be expanded at this point");
- return I->second;
+ Value *V = ExpandedSCEVs.lookup(Step);
+ assert(V && "SCEV must be expanded at this point");
+ return V;
}
/// Knowing that loop \p L executes a single vector iteration, add instructions
@@ -9860,8 +9860,8 @@
auto *ExpandR = dyn_cast<VPExpandSCEVRecipe>(&R);
if (!ExpandR)
continue;
- auto *ExpandedVal =
- Plan.getOrAddLiveIn(ExpandedSCEVs.find(ExpandR->getSCEV())->second);
+ VPValue *ExpandedVal =
+ Plan.getOrAddLiveIn(ExpandedSCEVs.lookup(ExpandR->getSCEV()));
ExpandR->replaceAllUsesWith(ExpandedVal);
if (Plan.getTripCount() == ExpandR)
Plan.resetTripCount(ExpandedVal);