[llvm] [AMDGPU] SCC live interval must be recomputed after CF lowering (PR #81817)
Carl Ritson via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 14 19:19:13 PST 2024
https://github.com/perlfu created https://github.com/llvm/llvm-project/pull/81817
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.
>From 5c91b2013b22f689a2d3c0fb158e02d6da23fc82 Mon Sep 17 00:00:00 2001
From: Carl Ritson <carl.ritson at amd.com>
Date: Thu, 15 Feb 2024 11:49:13 +0900
Subject: [PATCH] [AMDGPU] SCC live interval must be recomputed after CF
lowering
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.
---
llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
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);
More information about the llvm-commits
mailing list