Skip to content

Commit bf4c941

Browse files
artagnonrorth
authored andcommitted
[LV] Prefer DenseMap::lookup over find (NFC) (llvm#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.
1 parent a66b464 commit bf4c941

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,9 +2548,9 @@ static Value *getExpandedStep(const InductionDescriptor &ID,
25482548
return C->getValue();
25492549
if (auto *U = dyn_cast<SCEVUnknown>(Step))
25502550
return U->getValue();
2551-
auto I = ExpandedSCEVs.find(Step);
2552-
assert(I != ExpandedSCEVs.end() && "SCEV must be expanded at this point");
2553-
return I->second;
2551+
Value *V = ExpandedSCEVs.lookup(Step);
2552+
assert(V && "SCEV must be expanded at this point");
2553+
return V;
25542554
}
25552555

25562556
/// Knowing that loop \p L executes a single vector iteration, add instructions
@@ -9860,8 +9860,8 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98609860
auto *ExpandR = dyn_cast<VPExpandSCEVRecipe>(&R);
98619861
if (!ExpandR)
98629862
continue;
9863-
auto *ExpandedVal =
9864-
Plan.getOrAddLiveIn(ExpandedSCEVs.find(ExpandR->getSCEV())->second);
9863+
VPValue *ExpandedVal =
9864+
Plan.getOrAddLiveIn(ExpandedSCEVs.lookup(ExpandR->getSCEV()));
98659865
ExpandR->replaceAllUsesWith(ExpandedVal);
98669866
if (Plan.getTripCount() == ExpandR)
98679867
Plan.resetTripCount(ExpandedVal);

0 commit comments

Comments
 (0)