[clang] [llvm] [RegisterCoalescer] Improve register allocation for return values by limiting rematerialization (PR #163047)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 06:48:47 PST 2025


================
@@ -1326,6 +1326,79 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
   if (!TII->isAsCheapAsAMove(*DefMI))
     return false;
 
+  // Skip rematerialization for physical registers used as return values within
+  // the same basic block to enable better coalescing.
+  if (DstReg.isPhysical()) {
----------------
antoniofrighetto wrote:

Could you please move this into a dedicated helper, e.g., `shouldSkipRematerializationForReturn` and add a brief doc-comment?

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


More information about the llvm-commits mailing list