Skip to content

Commit b2b267e

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#130543)
1 parent 5addbf0 commit b2b267e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4672,8 +4672,8 @@ class TypePromotionHelper {
46724672
static void addPromotedInst(InstrToOrigTy &PromotedInsts,
46734673
Instruction *ExtOpnd, bool IsSExt) {
46744674
ExtType ExtTy = IsSExt ? SignExtension : ZeroExtension;
4675-
InstrToOrigTy::iterator It = PromotedInsts.find(ExtOpnd);
4676-
if (It != PromotedInsts.end()) {
4675+
auto [It, Inserted] = PromotedInsts.try_emplace(ExtOpnd);
4676+
if (!Inserted) {
46774677
// If the new extension is same as original, the information in
46784678
// PromotedInsts[ExtOpnd] is still correct.
46794679
if (It->second.getInt() == ExtTy)
@@ -4684,7 +4684,7 @@ class TypePromotionHelper {
46844684
// BothExtension.
46854685
ExtTy = BothExtension;
46864686
}
4687-
PromotedInsts[ExtOpnd] = TypeIsSExt(ExtOpnd->getType(), ExtTy);
4687+
It->second = TypeIsSExt(ExtOpnd->getType(), ExtTy);
46884688
}
46894689

46904690
/// Utility function to query the original type of instruction \p Opnd

0 commit comments

Comments
 (0)