[llvm] [LV] Prefer DenseMap::lookup over find (NFC) (PR #141809)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 06:52:31 PDT 2025


================
@@ -2566,9 +2566,9 @@ static Value *getExpandedStep(const InductionDescriptor &ID,
     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;
+  auto *V = ExpandedSCEVs.lookup(Step);
----------------
artagnon wrote:

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.

https://github.com/llvm/llvm-project/pull/141809


More information about the llvm-commits mailing list