[llvm] Reland "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG" (PR #168353)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 04:23:30 PST 2025
================
@@ -1935,6 +1954,79 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr())
Reads = DstInt->liveAt(LIS->getInstructionIndex(*UseMI));
+ bool RequiresImplicitRedef = false;
+ if (!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:
+ // %1.sub32:gr64 = INSTX
+ // undef %1.sub8:gr64 = INSTY , implicit-def %1
----------------
sdesmalen-arm wrote:
The undef means that the 64-bits of %1 are considered `undef` before the assigning the `.sub8` result, and the `implicit-def %1` would mean that the entire contents (not just the low 8bits) would be written. So as a consequence of either/both, the other bits of `%1` are not read. Either way, I've updated the wording.
https://github.com/llvm/llvm-project/pull/168353
More information about the llvm-commits
mailing list