[llvm] Reland "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG" (PR #168353)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 29 04:02:21 PST 2025
================
@@ -1935,6 +1955,82 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr())
Reads = DstInt->liveAt(LIS->getInstructionIndex(*UseMI));
+ bool RequiresImplicitRedef = false;
+ if (SubregToRegSrcInsts && !SubregToRegSrcInsts->empty()) {
+ // We can only add an implicit-def and undef if the sub registers match,
+ // e.g.
+ // %0:gr32 = INSTX
+ // %0.sub8:gr32 = INSTY // top 24 bits of %0 still defined
+ // %1:gr64 = SUBREG_TO_REG 0, %0, %subreg.sub32
+ //
+ // This cannot be transformed into:
----------------
dianqk wrote:
Should `SubregToRegSrcInsts` (only) include `%0:gr32 = INSTX`?
IIUC, this should be transformed into:
```
undef %1.sub32:gr64 = INSTX, implicit-def %1
%1.sub8:gr64 = INSTY
```
https://github.com/llvm/llvm-project/pull/168353
More information about the llvm-commits
mailing list