[llvm] [CodeGen] Fix stale comment about register coalescing order (PR #146762)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 07:21:14 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: Tomer Shafir (tomershafir)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/146762.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/RegisterCoalescer.cpp (+4-4) 


``````````diff
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))

``````````

</details>


https://github.com/llvm/llvm-project/pull/146762


More information about the llvm-commits mailing list