[llvm] [AMDGPU] Fix moveToValue for copy to phys SGPR (PR #76715)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 2 05:38:58 PST 2024


================
@@ -7198,6 +7198,17 @@ void SIInstrInfo::moveToVALUImpl(SIInstrWorklist &Worklist,
     Register DstReg = Inst.getOperand(0).getReg();
     const TargetRegisterClass *NewDstRC = getDestEquivalentVGPRClass(Inst);
 
+    // If it's a copy of a VGPR to a physical SGPR, insert a V_READFIRSTLANE and
+    // hope for the best.
+    if (Inst.isCopy() && DstReg.isPhysical() &&
+        RI.isVGPR(MRI, Inst.getOperand(1).getReg())) {
+      BuildMI(*Inst.getParent(), &Inst, Inst.getDebugLoc(),
+              get(AMDGPU::V_READFIRSTLANE_B32), Inst.getOperand(0).getReg())
----------------
arsenm wrote:

This is only going to work for 32-bit registers but still an improvement 

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


More information about the llvm-commits mailing list