[llvm] [CodeGen] Fix stale comment about register coalescing order (PR #146762)
Tomer Shafir via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 12:33:20 PDT 2025
https://github.com/tomershafir created https://github.com/llvm/llvm-project/pull/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.
>From 74e86d2bec4b7fc4b59897c46fb1496e665c59c0 Mon Sep 17 00:00:00 2001
From: tomershafir <tomer.shafir8 at gmail.com>
Date: Wed, 2 Jul 2025 22:28:03 +0300
Subject: [PATCH] [CodeGen] Fix stale comment about register coalescing order
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.
---
llvm/lib/CodeGen/RegisterCoalescer.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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