[llvm] [LV] Prefer DenseMap::lookup over find (NFC) (PR #141809)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 06:45:40 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);
----------------
david-arm wrote:
This change looks perfectly reasonable to me, but why "prefer" `lookup` to `find`? Both `lookup` and `find` still call `doFind` so the work done is the same, so I assume the main reason is because it makes this assertion slightly easier to write? Similarly it reduces a few characters in the second instance below.
https://github.com/llvm/llvm-project/pull/141809
More information about the llvm-commits
mailing list