[llvm] [AMDGPU]: Add support to unpack V_PK_MOV_B32 (PR #163464)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 11:02:53 PST 2025


================
@@ -645,6 +667,28 @@ void SIPreEmitPeephole::performF32Unpacking(MachineInstr &I) {
   uint16_t UnpackedOpcode = mapToUnpackedOpcode(I);
   assert(UnpackedOpcode != std::numeric_limits<uint16_t>::max() &&
          "Unsupported Opcode");
+  // V_MOV_B32 does not support source modifiers. Without source modifiers, we
+  // cannot be faithful to the packed instruction semantics in few cases. This
+  // is true when the packed instruction has NEG and NEG_HI modifiers. We should
+  // abort unpacking if:
+  // 1. hi/lo bits selected by OPSEL for src0 are also marked by NEG or NEG_HI.
+  // 2. hi/lo bits selected by OPSEL_HI for src1 are also marked by NEG or
+  // NEG_HI.
+  // Packed instructions do not specify ABS modifiers, so we can safely ignore
+  // those.
+  if (!AMDGPU::hasNamedOperand(UnpackedOpcode,
+                               AMDGPU::OpName::src0_modifiers)) {
+    unsigned Src0Mods =
+        TII->getNamedOperand(I, AMDGPU::OpName::src0_modifiers)->getImm();
----------------
arsenm wrote:

Remove the hasNamedOperand check / fold it together with getNamedOperand like above 

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


More information about the llvm-commits mailing list