aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstrBundle.cpp
diff options
context:
space:
mode:
authorBjörn Pettersson <bjorn.a.pettersson@ericsson.com>2025-08-27 08:54:02 +0200
committerGitHub <noreply@github.com>2025-08-27 08:54:02 +0200
commit58f3b0dd8d7b2e09d82dae95908cf34ef50468af (patch)
tree972a331b3ec3c9b4c4f47fb8824d2d846f3b3924 /llvm/lib/CodeGen/MachineInstrBundle.cpp
parent640dc21242b69b63f9c130b8dc62bad32c4db4a3 (diff)
downloadllvm-58f3b0dd8d7b2e09d82dae95908cf34ef50468af.zip
llvm-58f3b0dd8d7b2e09d82dae95908cf34ef50468af.tar.gz
llvm-58f3b0dd8d7b2e09d82dae95908cf34ef50468af.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstrBundle.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstrBundle.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp
index d9e8484..5830ecf 100644
--- a/llvm/lib/CodeGen/MachineInstrBundle.cpp
+++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp
@@ -173,6 +173,9 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB,
if (LocalDefs.insert(Reg)) {
if (MO.isDead())
DeadDefSet.insert(Reg);
+ else if (Reg.isPhysical())
+ for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg()))
+ LocalDefsP.set(Unit);
} else {
// Re-defined inside the bundle, it's no longer killed.
KilledDefSet.erase(Reg);
@@ -181,11 +184,6 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB,
DeadDefSet.erase(Reg);
}
}
-
- if (!MO.isDead() && Reg.isPhysical()) {
- for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg()))
- LocalDefsP.set(Unit);
- }
}
// Set FrameSetup/FrameDestroy for the bundle. If any of the instructions