Skip to content

Commit 9a3ef94

Browse files
[X86] Avoid repeated hash lookups (NFC)
1 parent 95e38ba commit 9a3ef94

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

llvm/lib/Target/X86/X86PreTileConfig.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -293,29 +293,30 @@ bool X86PreTileConfig::runOnMachineFunction(MachineFunction &MF) {
293293
SmallVector<MachineBasicBlock *, 8> CfgLiveInBBs;
294294
for (auto &MBB : MF) {
295295
size_t Pos = 0;
296+
auto &Info = BBVisitedInfo[&MBB];
296297
for (auto &MI : MBB) {
297298
++Pos;
298299
if (isAMXInstruction(MI)) {
299300
// If there's call before the AMX, we need to reload tile config.
300-
if (BBVisitedInfo[&MBB].LastCall)
301-
CfgNeedInsert.insert(BBVisitedInfo[&MBB].LastCall);
301+
if (Info.LastCall)
302+
CfgNeedInsert.insert(Info.LastCall);
302303
else // Otherwise, we need tile config to live in this BB.
303-
BBVisitedInfo[&MBB].NeedTileCfgLiveIn = true;
304+
Info.NeedTileCfgLiveIn = true;
304305
// Always record the first AMX in case there's shape def after it.
305-
if (!BBVisitedInfo[&MBB].FirstAMX)
306-
BBVisitedInfo[&MBB].FirstAMX = MIRef(&MI, &MBB, Pos);
306+
if (!Info.FirstAMX)
307+
Info.FirstAMX = MIRef(&MI, &MBB, Pos);
307308
} else if (MI.isCall() && isDestructiveCall(MI, AMXRegs)) {
308309
// Record the call only if the callee clobbers all AMX registers.
309-
BBVisitedInfo[&MBB].LastCall = MIRef(&MI, &MBB, Pos);
310+
Info.LastCall = MIRef(&MI, &MBB, Pos);
310311
}
311312
}
312-
if (BBVisitedInfo[&MBB].NeedTileCfgLiveIn) {
313+
if (Info.NeedTileCfgLiveIn) {
313314
if (&MBB == &MF.front())
314315
CfgNeedInsert.insert(MIRef(&MBB));
315316
else
316317
CfgLiveInBBs.push_back(&MBB);
317318
}
318-
if (BBVisitedInfo[&MBB].FirstAMX || BBVisitedInfo[&MBB].HasAMXRegLiveIn)
319+
if (Info.FirstAMX || Info.HasAMXRegLiveIn)
319320
for (auto *Succ : MBB.successors())
320321
if (!isLoopBackEdge(Succ, &MBB))
321322
BBVisitedInfo[Succ].HasAMXRegLiveIn = true;
@@ -344,16 +345,16 @@ bool X86PreTileConfig::runOnMachineFunction(MachineFunction &MF) {
344345
// Avoid to insert ldtilecfg before any shape defs.
345346
SmallVector<MachineBasicBlock *, 8> WorkList;
346347
for (auto &I : ShapeBBs) {
348+
auto &Info = BBVisitedInfo[I.first];
347349
// TODO: We can hoist shapes across BBs here.
348-
if (BBVisitedInfo[I.first].HasAMXRegLiveIn) {
350+
if (Info.HasAMXRegLiveIn) {
349351
// We are not able to config tile registers since the shape to config
350352
// is not defined yet. Emit error message and continue. The function
351353
// would not config tile registers.
352354
emitErrorMsg(MF);
353355
return false;
354356
}
355-
if (BBVisitedInfo[I.first].FirstAMX &&
356-
BBVisitedInfo[I.first].FirstAMX < I.second.back() &&
357+
if (Info.FirstAMX && Info.FirstAMX < I.second.back() &&
357358
!hoistShapesInBB(I.first, I.second)) {
358359
emitErrorMsg(MF);
359360
return false;
@@ -363,8 +364,9 @@ bool X86PreTileConfig::runOnMachineFunction(MachineFunction &MF) {
363364
while (!WorkList.empty()) {
364365
MachineBasicBlock *MBB = WorkList.pop_back_val();
365366
for (auto *Pred : MBB->predecessors()) {
366-
if (!BBVisitedInfo[Pred].TileCfgForbidden && !isLoopBackEdge(MBB, Pred)) {
367-
BBVisitedInfo[Pred].TileCfgForbidden = true;
367+
auto &Info = BBVisitedInfo[Pred];
368+
if (!Info.TileCfgForbidden && !isLoopBackEdge(MBB, Pred)) {
369+
Info.TileCfgForbidden = true;
368370
WorkList.push_back(Pred);
369371
}
370372
}

0 commit comments

Comments
 (0)