[llvm] 721adc1 - [CodeGen] Fix stale comment about register coalescing order (#146762)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 6 23:54:27 PDT 2025
Author: Tomer Shafir
Date: 2025-07-07T09:54:24+03:00
New Revision: 721adc18b77a000ce22470a8fb0e361a47812196
URL: https://github.com/llvm/llvm-project/commit/721adc18b77a000ce22470a8fb0e361a47812196
DIFF: https://github.com/llvm/llvm-project/commit/721adc18b77a000ce22470a8fb0e361a47812196.diff
LOG: [CodeGen] Fix stale comment about register coalescing order (#146762)
The register coalescer collects the copies forward, the stale comment
wasn't addressed back then by:
https://github.com/tomershafir/llvm-project/commit/75961ecc1a5b0dff6303df886ea9817248b78931.
This change updates the coment and also adds a similar one to the other
branch.
Added:
Modified:
llvm/lib/CodeGen/RegisterCoalescer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index 2d25f097348af..2d7987a2e1988 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -4152,10 +4152,8 @@ void RegisterCoalescer::copyCoalesceInMBB(MachineBasicBlock *MBB) {
if (JoinGlobalCopies) {
SmallVector<MachineInstr *, 2> LocalTerminals;
SmallVector<MachineInstr *, 2> GlobalTerminals;
- // Coalesce copies bottom-up to coalesce local defs before local uses. They
- // are not inherently easier to resolve, but slightly preferable until we
- // have local live range splitting. In particular this is required by
- // cmp+jmp macro fusion.
+ // Coalesce copies top-down to propagate coalescing and rematerialization
+ // forward.
for (MachineInstr &MI : *MBB) {
if (!MI.isCopyLike())
continue;
@@ -4177,6 +4175,8 @@ void RegisterCoalescer::copyCoalesceInMBB(MachineBasicBlock *MBB) {
WorkList.append(GlobalTerminals.begin(), GlobalTerminals.end());
} else {
SmallVector<MachineInstr *, 2> Terminals;
+ // Coalesce copies top-down to propagate coalescing and rematerialization
+ // forward.
for (MachineInstr &MII : *MBB)
if (MII.isCopyLike()) {
if (applyTerminalRule(MII))
More information about the llvm-commits
mailing list