[llvm] [AMDGPU] Save/Restore SCC bit across waterfall loop. (PR #68363)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 09:49:49 PDT 2023


================
@@ -6056,6 +6056,16 @@ loadMBUFScalarOperandsFromVGPR(const SIInstrInfo &TII, MachineInstr &MI,
   unsigned MovExecOpc = ST.isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
   const auto *BoolXExecRC = TRI->getRegClass(AMDGPU::SReg_1_XEXECRegClassID);
 
+  // Save SCC. Waterfall Loop may overwrite SCC.
+  Register SaveSCCReg;
+  bool SCCNotDead = (MBB.computeRegisterLiveness(TRI, AMDGPU::SCC, MI, 30) !=
+                     MachineBasicBlock::LQR_Dead);
+  if (SCCNotDead) {
+    SaveSCCReg = MRI.createVirtualRegister(&AMDGPU::SReg_32RegClass);
+    BuildMI(MBB, Begin, DL, TII.get(AMDGPU::COPY), SaveSCCReg)
----------------
jayfoad wrote:

Overall I think it might be better to emit S_CSELECT_B32 and S_CMP_LG_U32 directly here, instead of trying to use COPY.

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


More information about the llvm-commits mailing list