[llvm] 68bca17 - [AMDGPU] SILowerControlFlow: ensure EXEC/SCC interval recompute (#160459)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 02:30:43 PDT 2025


Author: Carl Ritson
Date: 2025-09-24T18:30:40+09:00
New Revision: 68bca1709f9ba4c217d29c77af903509c50c91b6

URL: https://github.com/llvm/llvm-project/commit/68bca1709f9ba4c217d29c77af903509c50c91b6
DIFF: https://github.com/llvm/llvm-project/commit/68bca1709f9ba4c217d29c77af903509c50c91b6.diff

LOG: [AMDGPU] SILowerControlFlow: ensure EXEC/SCC interval recompute (#160459)

Ensure live intervals for EXEC and SCC are removed on all paths which
generate instructions.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
index 115a020f44098..8586d6c18b361 100644
--- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
+++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
@@ -293,7 +293,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
@@ -363,9 +362,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) {
@@ -828,7 +824,10 @@ bool SILowerControlFlow::run(MachineFunction &MF) {
 
   optimizeEndCf();
 
-  if (LIS) {
+  if (LIS && 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);


        


More information about the llvm-commits mailing list