Skip to content

Commit 69b7011

Browse files
[TableGen] Avoid repeated hash lookups (NFC) (#132142)
1 parent c38ef58 commit 69b7011

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,12 +1809,11 @@ Intrinsic::DagEmitter::emitDagSaveTemp(const DagInit *DI) {
18091809
assert_with_loc(!N.empty(),
18101810
"save_temp() expects a name as the first argument");
18111811

1812-
assert_with_loc(Intr.Variables.find(N) == Intr.Variables.end(),
1813-
"Variable already defined!");
1814-
Intr.Variables[N] = Variable(A.first, N + Intr.VariablePostfix);
1812+
auto [It, Inserted] =
1813+
Intr.Variables.try_emplace(N, A.first, N + Intr.VariablePostfix);
1814+
assert_with_loc(Inserted, "Variable already defined!");
18151815

1816-
std::string S =
1817-
A.first.str() + " " + Intr.Variables[N].getName() + " = " + A.second;
1816+
std::string S = A.first.str() + " " + It->second.getName() + " = " + A.second;
18181817

18191818
return std::make_pair(Type::getVoid(), S);
18201819
}
@@ -2246,9 +2245,9 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
22462245
// Sorted by immediate argument index
22472246
ArrayRef<ImmCheck> Checks = Def->getImmChecks();
22482247

2249-
const auto it = Emitted.find(Def->getMangledName());
2250-
if (it != Emitted.end()) {
2251-
assert(areRangeChecksCompatible(Checks, it->second) &&
2248+
auto [It, Inserted] = Emitted.try_emplace(Def->getMangledName(), Checks);
2249+
if (!Inserted) {
2250+
assert(areRangeChecksCompatible(Checks, It->second) &&
22522251
"Neon intrinsics with incompatible immediate range checks cannot "
22532252
"share a builtin.");
22542253
continue; // Ensure this is emitted only once
@@ -2262,7 +2261,6 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
22622261
<< Check.getVecSizeInBits() << ");\n"
22632262
<< " break;\n";
22642263
}
2265-
Emitted[Def->getMangledName()] = Checks;
22662264
}
22672265

22682266
OS << "#endif\n\n";

0 commit comments

Comments
 (0)