Skip to content

Commit 2df51fd

Browse files
[Transforms] Avoid repeated hash lookups (NFC) (#132146)
1 parent 93507f6 commit 2df51fd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4392,13 +4392,15 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
43924392
DenseMap<VPRecipeBase *, unsigned> Numbering;
43934393
unsigned I = 0;
43944394
for (auto &Pair : InvalidCosts)
4395-
if (!Numbering.count(Pair.first))
4396-
Numbering[Pair.first] = I++;
4395+
if (Numbering.try_emplace(Pair.first, I).second)
4396+
++I;
43974397

43984398
// Sort the list, first on recipe(number) then on VF.
43994399
sort(InvalidCosts, [&Numbering](RecipeVFPair &A, RecipeVFPair &B) {
4400-
if (Numbering[A.first] != Numbering[B.first])
4401-
return Numbering[A.first] < Numbering[B.first];
4400+
unsigned NA = Numbering[A.first];
4401+
unsigned NB = Numbering[B.first];
4402+
if (NA != NB)
4403+
return NA < NB;
44024404
return ElementCount::isKnownLT(A.second, B.second);
44034405
});
44044406

0 commit comments

Comments
 (0)