[llvm] [CodeGen][AMDGPU] TwoAddress: Only skip undef COPY at REG_SEQUENCE lowering when there is Live info or no uses for subreg (PR #175598)

Felipe Quezada via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 22 11:56:39 PST 2026


================
@@ -2006,16 +2006,33 @@ void TwoAddressInstructionImpl::eliminateRegSequence(
     }
   }
 
+  // If there are no live intervals information, we scan the use list once
+  // in order to find which subregisters are used.
+  LaneBitmask UsedLanes = LaneBitmask::getNone();
+  if (!LIS) {
+    for (MachineOperand &Use : MRI->use_nodbg_operands(DstReg)) {
+      auto SubReg = Use.getSubReg();
+      if (SubReg) {
+        UsedLanes |= TRI->getSubRegIndexLaneMask(SubReg);
+      }
+    }
+  }
+
   LaneBitmask UndefLanes = LaneBitmask::getNone();
   bool DefEmitted = false;
   for (unsigned i = 1, e = MI.getNumOperands(); i < e; i += 2) {
     MachineOperand &UseMO = MI.getOperand(i);
     Register SrcReg = UseMO.getReg();
     unsigned SubIdx = MI.getOperand(i+1).getImm();
     // Nothing needs to be inserted for undef operands.
+    // Unless there's no live intervals, and they are used at a later
----------------
kezada94 wrote:

Thanks!

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


More information about the llvm-commits mailing list