[llvm] [CodeGen][AMDGPU] Insert IMPLICIT_DEF for undef subreg operands in REG_SEQUENCE and preserve them during register coalescing (PR #189153)

via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 28 02:46:05 PDT 2026


https://github.com/adeshcom14 created https://github.com/llvm/llvm-project/pull/189153

Currently, when TwoAddressInstructionPass lowers a REG_SEQUENCE, undef subreg operands are conditionally skipped based on LiveIntervals availability or downstream use scanning. This can leave undefined sublanes of a tuple register without any definition point. When the Register Coalescer later merges intervals involving these registers, it encounters sublane masks with no corresponding definition causing a crash.
Now, eliminateRegSequence always emits explicit IMPLICIT_DEF instructions for undef subreg operands, ensuring every sublane has a proper definition. 

Additionally, the Register Coalescer unconditionally marked all IMPLICIT_DEF values as erasable, causing subreg IMPLICIT_DEFs that define undef sublanes of a tuple to be erased during coalescing. This left the merged live interval with sublane masks that had no definition. 
Now the subreg IMPLICIT_DEFs are no longer marked as erasable. For non-overlapping lanes, the conflict is resolved with CR_Replace instead of CR_Erase to preserve the sublane definition.

The regression test coalescer-subreg-implicit-def.mir exercises both passes on a case that previously crashed.

Fixes [LCOMPILER-101]

The server is unavailable at this time. Please wait a few minutes before you try again.


More information about the llvm-commits mailing list