[llvm] [AMDGPU] - Generate s_bitreplicate_b64_b32 (PR #69209)

Jessica Del via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 07:26:46 PDT 2023


================
@@ -6297,6 +6297,14 @@ SIInstrInfo::legalizeOperands(MachineInstr &MI,
     return CreatedBB;
   }
 
+  // Legalize S_BITREPLICATE
+  if (MI.getOpcode() == AMDGPU::S_BITREPLICATE_B64_B32) {
+    MachineOperand &Src = MI.getOperand(1);
+    if (Src.isReg() && RI.hasVectorRegisters(MRI.getRegClass(Src.getReg())))
+      Src.setReg(readlaneVGPRToSGPR(Src.getReg(), MI, MRI));
+    return CreatedBB;
+  }
----------------
OutOfCache wrote:

This unfortunately seems necessary.

The FixSGPRCopies pass incorrectly decides to turn `s_bitreplicate` into a VALU instruction when there is a VGPR input. This is a similar issue to [D45826](https://reviews.llvm.org/D45826).

I refrained from writing a helper method for now because there would be only two calls for now. If it makes sense to add one, I will.

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


More information about the llvm-commits mailing list