Skip to content

Commit 58f3b0d

Browse files
authored
[CodeGen] Optimize/simplify finalizeBundle. NFC (#155448)
When tracking defs in finalizeBundle two sets are used. LocalDefs is used to track defined virtual and physical registers, while LocalDefsP is used to track defined register units for the physical registers. This patch moves the updates of LocalDefsP to only iterate over regunits when a new physical register is added to LocalDefs. When the physical register already is present in LocalDefs, then the corresponding register units are present in LocalDefsP. So it was a waste of time to add them to the set again.
1 parent 640dc21 commit 58f3b0d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/lib/CodeGen/MachineInstrBundle.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB,
173173
if (LocalDefs.insert(Reg)) {
174174
if (MO.isDead())
175175
DeadDefSet.insert(Reg);
176+
else if (Reg.isPhysical())
177+
for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg()))
178+
LocalDefsP.set(Unit);
176179
} else {
177180
// Re-defined inside the bundle, it's no longer killed.
178181
KilledDefSet.erase(Reg);
@@ -181,11 +184,6 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB,
181184
DeadDefSet.erase(Reg);
182185
}
183186
}
184-
185-
if (!MO.isDead() && Reg.isPhysical()) {
186-
for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg()))
187-
LocalDefsP.set(Unit);
188-
}
189187
}
190188

191189
// Set FrameSetup/FrameDestroy for the bundle. If any of the instructions

0 commit comments

Comments
 (0)