[llvm] [AMDGPU] Extend wide VGPR copy expansion to 96-bit copies (PR #214561)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 09:04:34 PDT 2026


================
@@ -1166,6 +1165,50 @@ void SIInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
     }
   }
 
+  // If there is an overlap, we can't kill the super-register on the last
+  // instruction, since it will also kill the components made live by this def.
+  const bool Overlap = RI.regsOverlap(SrcReg, DestReg);
+  const bool CanKillSuperReg = KillSrc && !Overlap;
+
+  if (Size == 96 && ST.hasVMovB64Inst() && RI.hasVGPRs(RC) &&
+      (SrcRC == RC || RI.isSGPRClass(SrcRC))) {
+    unsigned DestIndex = RI.getHWRegIndex(DestReg);
+    unsigned SrcIndex = RI.getHWRegIndex(SrcReg);
+    bool SameParity = (DestIndex % 2) == (SrcIndex % 2);
+
+    if (!ST.needsAlignedVGPRs() || SameParity) {
+      bool WideIsLow = !ST.needsAlignedVGPRs() || DestIndex % 2 == 0;
+      unsigned WideSubIdx = WideIsLow ? AMDGPU::sub0_sub1 : AMDGPU::sub1_sub2;
+      unsigned NarrowSubIdx = WideIsLow ? AMDGPU::sub2 : AMDGPU::sub0;
+
+      Register WideDst = RI.getSubReg(DestReg, WideSubIdx);
+      Register WideSrc = RI.getSubReg(SrcReg, WideSubIdx);
+      Register NarrowDst = RI.getSubReg(DestReg, NarrowSubIdx);
+      Register NarrowSrc = RI.getSubReg(SrcReg, NarrowSubIdx);
+
+      assert(WideDst && WideSrc && NarrowDst && NarrowSrc &&
+             "Failed to find subregs.");
+
+      auto EmitMov = [&](unsigned Opc, Register Dst, Register Src,
----------------
arsenm wrote:

Don't need this lambda 

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


More information about the llvm-commits mailing list