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);