aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-03-20 09:11:56 -0700
committerGitHub <noreply@github.com>2025-03-20 09:11:56 -0700
commit2df51fd9c491ef1ad90fbad5ce18ea8ff8bd3117 (patch)
tree5abcf7b1c1feb125085d2fb60d6f6f12da0b22ef
parent93507f6c6779d9585e5b2d0eb775354929626757 (diff)
downloadllvm-2df51fd9c491ef1ad90fbad5ce18ea8ff8bd3117.zip
llvm-2df51fd9c491ef1ad90fbad5ce18ea8ff8bd3117.tar.gz
llvm-2df51fd9c491ef1ad90fbad5ce18ea8ff8bd3117.tar.bz2
[Transforms] Avoid repeated hash lookups (NFC) (#132146)
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 584da9b..8c40c37 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4392,13 +4392,15 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
DenseMap<VPRecipeBase *, unsigned> Numbering;
unsigned I = 0;
for (auto &Pair : InvalidCosts)
- if (!Numbering.count(Pair.first))
- Numbering[Pair.first] = I++;
+ if (Numbering.try_emplace(Pair.first, I).second)
+ ++I;
// Sort the list, first on recipe(number) then on VF.
sort(InvalidCosts, [&Numbering](RecipeVFPair &A, RecipeVFPair &B) {
- if (Numbering[A.first] != Numbering[B.first])
- return Numbering[A.first] < Numbering[B.first];
+ unsigned NA = Numbering[A.first];
+ unsigned NB = Numbering[B.first];
+ if (NA != NB)
+ return NA < NB;
return ElementCount::isKnownLT(A.second, B.second);
});