[llvm] [AMDGPU] Select 64-bit VGPR copy opcode from the operand register class in copyPhysReg. (PR #219562)

Valery Pykhtin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 09:58:51 PDT 2026


================
@@ -1166,15 +1177,29 @@ void SIInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
   } else if (RI.hasVGPRs(RC) && RI.isAGPRClass(SrcRC)) {
     Opcode = AMDGPU::V_ACCVGPR_READ_B32_e64;
   } else if ((Size % 64 == 0) && RI.hasVGPRs(RC) &&
-             (RI.isProperlyAlignedRC(*RC) &&
-              (SrcRC == RC || RI.isSGPRClass(SrcRC)))) {
+             (SrcRC == RC || RI.isSGPRClass(SrcRC))) {
     // TODO: In 96-bit case, could do a 64-bit mov and then a 32-bit mov.
-    if (ST.hasVMovB64Inst()) {
-      Opcode = AMDGPU::V_MOV_B64_e32;
-      EltSize = 8;
-    } else if (ST.hasPkMovB32()) {
-      Opcode = AMDGPU::V_PK_MOV_B32;
-      EltSize = 8;
+    unsigned NewOpcode = AMDGPU::INSTRUCTION_LIST_END;
+    if (ST.hasVMovB64Inst())
+      NewOpcode = AMDGPU::V_MOV_B64_e32;
+    else if (ST.hasPkMovB32())
+      NewOpcode = AMDGPU::V_PK_MOV_B32;
+
+    if (NewOpcode != AMDGPU::INSTRUCTION_LIST_END) {
+      // The copy is expanded into 64-bit component moves below, so the wide
+      // move is usable only if it can encode each component. Components of a
+      // contiguous tuple share the base register's alignment, so it is enough
+      // to test the low component (sub0_sub1); for a 64-bit destination that
+      // component is the whole register. Otherwise fall through to the
+      // element-wise V_MOV_B32 expansion below (a Size == 64 copy reaches here
----------------
vpykhtin wrote:

removed ai slop

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


More information about the llvm-commits mailing list