Skip to content

Commit 34c7d89

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#125813)
1 parent fe0c37f commit 34c7d89

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,12 +748,11 @@ class InterleavedAccessInfo {
748748
/// \returns the newly created interleave group.
749749
InterleaveGroup<Instruction> *
750750
createInterleaveGroup(Instruction *Instr, int Stride, Align Alignment) {
751-
assert(!InterleaveGroupMap.count(Instr) &&
752-
"Already in an interleaved access group");
753-
InterleaveGroupMap[Instr] =
754-
new InterleaveGroup<Instruction>(Instr, Stride, Alignment);
755-
InterleaveGroups.insert(InterleaveGroupMap[Instr]);
756-
return InterleaveGroupMap[Instr];
751+
auto [It, Inserted] = InterleaveGroupMap.try_emplace(Instr);
752+
assert(Inserted && "Already in an interleaved access group");
753+
It->second = new InterleaveGroup<Instruction>(Instr, Stride, Alignment);
754+
InterleaveGroups.insert(It->second);
755+
return It->second;
757756
}
758757

759758
/// Release the group and remove all the relationships.

0 commit comments

Comments
 (0)