[llvm] [RegisterCoalescer] Avoid retrying high-cost joins for live intervals (PR #207976)

Mingjie Xu via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 8 19:51:52 PDT 2026


================
@@ -2222,7 +2228,10 @@ bool RegisterCoalescer::joinCopy(
 
     // Otherwise, we are unable to join the intervals.
     LLVM_DEBUG(dbgs() << "\tInterference!\n");
-    Again = true; // May be possible to coalesce later.
+    // A high-cost interval is already too expensive to retry.  Keeping the copy
+    // in WorkList would make every subsequent successful join rescan it again,
+    // which can dominate compile time.
+    Again = !LastJoinSkippedHighCost; // May be possible to coalesce later.
----------------
Enna1 wrote:

Can `LastJoinSkippedHighCost` be a local variable in `joinCopy()`? 
```Cpp
bool joinIntervals(CoalescerPair &CP, bool &JoinSkippedHighCost);
bool joinVirtRegs(CoalescerPair &CP, bool &JoinSkippedHighCost);
```

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


More information about the llvm-commits mailing list