[llvm] [AMDGPU] SCC live interval must be recomputed after CF lowering (PR #81817)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 19:19:45 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Carl Ritson (perlfu)

<details>
<summary>Changes</summary>

Most operations added or removed during CF lowering interact with SCC.  As with EXEC the live interval of SCC must be recomputed. Tidy up RegUnit recomputation requests to end of pass if any work was done.

---
Full diff: https://github.com/llvm/llvm-project/pull/81817.diff


1 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp (+5-6) 


``````````diff
diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
index f178324dbbe246..2e6f6463d61dae 100644
--- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
+++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
@@ -292,7 +292,6 @@ void SILowerControlFlow::emitIf(MachineInstr &MI) {
   LIS->InsertMachineInstrInMaps(*SetExec);
   LIS->InsertMachineInstrInMaps(*NewBr);
 
-  LIS->removeAllRegUnitsForPhysReg(AMDGPU::EXEC);
   MI.eraseFromParent();
 
   // FIXME: Is there a better way of adjusting the liveness? It shouldn't be
@@ -362,9 +361,6 @@ void SILowerControlFlow::emitElse(MachineInstr &MI) {
   RecomputeRegs.insert(SrcReg);
   RecomputeRegs.insert(DstReg);
   LIS->createAndComputeVirtRegInterval(SaveReg);
-
-  // Let this be recomputed.
-  LIS->removeAllRegUnitsForPhysReg(AMDGPU::EXEC);
 }
 
 void SILowerControlFlow::emitIfBreak(MachineInstr &MI) {
@@ -932,8 +928,6 @@ bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) {
       case AMDGPU::SI_INIT_EXEC:
       case AMDGPU::SI_INIT_EXEC_FROM_INPUT:
         lowerInitExec(MBB, MI);
-        if (LIS)
-          LIS->removeAllRegUnitsForPhysReg(AMDGPU::EXEC);
         Changed = true;
         break;
 
@@ -951,6 +945,11 @@ bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) {
   optimizeEndCf();
 
   if (LIS) {
+    if (Changed) {
+      // These will need to be recomputed for insertions and removals.
+      LIS->removeAllRegUnitsForPhysReg(AMDGPU::EXEC);
+      LIS->removeAllRegUnitsForPhysReg(AMDGPU::SCC);
+    }
     for (Register Reg : RecomputeRegs) {
       LIS->removeInterval(Reg);
       LIS->createAndComputeVirtRegInterval(Reg);

``````````

</details>


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


More information about the llvm-commits mailing list