[llvm] [RegAlloc] Trace through COPYs to find rematerializable definitions (PR #190955)
Romanov Vlad via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 03:29:36 PDT 2026
================
@@ -680,10 +680,36 @@ bool InlineSpiller::reMaterializeFor(LiveInterval &VirtReg, MachineInstr &MI) {
// live interval; this happens if we rematted to all uses, and
// then further split one of those live ranges.
if (!DefMI) {
- markValueUsed(&VirtReg, ParentVNI);
- LLVM_DEBUG(dbgs() << "\tcannot remat missing def for " << UseIdx << '\t'
- << MI);
- return false;
+ // Try to find the rematerializable definition by tracing through COPY
+ // chains.
+ MachineInstr *CurDef = MRI.getUniqueVRegDef(VirtReg.reg());
+ LLVM_DEBUG(dbgs() << "\ttracing COPY chain from "
+ << printReg(VirtReg.reg(), &TRI) << ", initial def: "
+ << (CurDef ? TII.getName(CurDef->getOpcode()) : "null")
+ << "\n");
+ while (CurDef && CurDef->isCopy() && !CurDef->getOperand(0).getSubReg() &&
+ !CurDef->getOperand(1).getSubReg()) {
----------------
romanovvlad wrote:
Thanks! Using isFullCopy now.
https://github.com/llvm/llvm-project/pull/190955
More information about the llvm-commits
mailing list