Skip to content

Commit 91c188b

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (llvm#126002)
1 parent 975bba6 commit 91c188b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/include/llvm/CodeGen/MachineRegisterInfo.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,10 @@ class MachineRegisterInfo {
810810
void setRegAllocationHint(Register VReg, unsigned Type, Register PrefReg) {
811811
assert(VReg.isVirtual());
812812
RegAllocHints.grow(Register::index2VirtReg(getNumVirtRegs()));
813-
RegAllocHints[VReg].first = Type;
814-
RegAllocHints[VReg].second.clear();
815-
RegAllocHints[VReg].second.push_back(PrefReg);
813+
auto &Hint = RegAllocHints[VReg];
814+
Hint.first = Type;
815+
Hint.second.clear();
816+
Hint.second.push_back(PrefReg);
816817
}
817818

818819
/// addRegAllocationHint - Add a register allocation hint to the hints
@@ -843,9 +844,9 @@ class MachineRegisterInfo {
843844
assert(VReg.isVirtual());
844845
if (!RegAllocHints.inBounds(VReg))
845846
return {0, Register()};
846-
Register BestHint = (RegAllocHints[VReg.id()].second.size() ?
847-
RegAllocHints[VReg.id()].second[0] : Register());
848-
return {RegAllocHints[VReg.id()].first, BestHint};
847+
auto &Hint = RegAllocHints[VReg.id()];
848+
Register BestHint = (Hint.second.size() ? Hint.second[0] : Register());
849+
return {Hint.first, BestHint};
849850
}
850851

851852
/// getSimpleHint - same as getRegAllocationHint except it will only return

0 commit comments

Comments
 (0)