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

Sirish Pande via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 13:30:21 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)
----------------
srpande wrote:

This is a good point. Implementing this. I will not make any change SIFixSGPRCopies.cpp

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


More information about the llvm-commits mailing list