Skip to content

Commit bea2803

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#111274)
1 parent abdf4ca commit bea2803

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

llvm/lib/CodeGen/RegisterBankInfo.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,10 @@ const TargetRegisterClass *
103103
RegisterBankInfo::getMinimalPhysRegClass(Register Reg,
104104
const TargetRegisterInfo &TRI) const {
105105
assert(Reg.isPhysical() && "Reg must be a physreg");
106-
const auto &RegRCIt = PhysRegMinimalRCs.find(Reg);
107-
if (RegRCIt != PhysRegMinimalRCs.end())
108-
return RegRCIt->second;
109-
const TargetRegisterClass *PhysRC = TRI.getMinimalPhysRegClassLLT(Reg, LLT());
110-
PhysRegMinimalRCs[Reg] = PhysRC;
111-
return PhysRC;
106+
const auto [RegRCIt, Inserted] = PhysRegMinimalRCs.try_emplace(Reg);
107+
if (Inserted)
108+
RegRCIt->second = TRI.getMinimalPhysRegClassLLT(Reg, LLT());
109+
return RegRCIt->second;
112110
}
113111

114112
const RegisterBank *RegisterBankInfo::getRegBankFromConstraints(

0 commit comments

Comments
 (0)