[llvm] [AMDGPU] SILowerControlFlow: ensure EXEC/SCC interval recompute (PR #160459)
Carl Ritson via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 24 01:04:08 PDT 2025
https://github.com/perlfu created https://github.com/llvm/llvm-project/pull/160459
Ensure live intervals for EXEC and SCC are removed on all paths which generate instructions.
>From ea00394b8a263fc5daa9005958747d1b4a35c211 Mon Sep 17 00:00:00 2001
From: Carl Ritson <carl.ritson at amd.com>
Date: Wed, 24 Sep 2025 15:29:52 +0900
Subject: [PATCH] [AMDGPU] SILowerControlFlow: ensure EXEC/SCC interval
recompute
Ensure live intervals for EXEC and SCC are removed on all paths
which generate instructions.
---
llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
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