[llvm] RegisterCoalescer: Fix assert on remat to copy-to-physreg with subregs (PR #121734)

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 08:17:17 PST 2025


================
@@ -1339,6 +1334,32 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
   if (SrcIdx && DstIdx)
     return false;
 
+  // Only support subregister destinations when the def is read-undef.
+  MachineOperand &DstOperand = CopyMI->getOperand(0);
+  Register CopyDstReg = DstOperand.getReg();
+  if (DstOperand.getSubReg() && !DstOperand.isUndef())
+    return false;
+
+  // Only support subregister destinations when the def is read-undef, in the
+  // physical register case. We're widening the def and need to avoid clobbering
----------------
qcolombet wrote:

I would start the comment with: "In the physical register case checking that the def is read-undef is not enough [...]" instead of repeating the beginning of the previous comment.

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


More information about the llvm-commits mailing list