[PATCH] D158141: [AMDGPU] SILowerControlFlow: fix preservation of LiveIntervals
Carl Ritson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 16 22:03:27 PDT 2023
critson created this revision.
critson added reviewers: arsenm, foad, rampitec.
Herald added subscribers: StephenFan, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
critson requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
In emitElse live interval for SI_ELSE source must be recalculated
as SI_ELSE is removed, and new user is placed at block start.
In emitIfBreak live interval for new created AndReg must be
computed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158141
Files:
llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
Index: llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
+++ llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp
@@ -309,6 +309,7 @@
const DebugLoc &DL = MI.getDebugLoc();
Register DstReg = MI.getOperand(0).getReg();
+ Register SrcReg = MI.getOperand(1).getReg();
MachineBasicBlock::iterator Start = MBB.begin();
@@ -319,7 +320,7 @@
BuildMI(MBB, Start, DL, TII->get(OrSaveExecOpc), SaveReg)
.add(MI.getOperand(1)); // Saved EXEC
if (LV)
- LV->replaceKillInstruction(MI.getOperand(1).getReg(), MI, *OrSaveExec);
+ LV->replaceKillInstruction(SrcReg, MI, *OrSaveExec);
MachineBasicBlock *DestBB = MI.getOperand(2).getMBB();
@@ -331,9 +332,6 @@
.addReg(Exec)
.addReg(SaveReg);
- if (LIS)
- LIS->InsertMachineInstrInMaps(*And);
-
MachineInstr *Xor =
BuildMI(MBB, ElsePt, DL, TII->get(XorTermrOpc), Exec)
.addReg(Exec)
@@ -356,11 +354,14 @@
MI.eraseFromParent();
LIS->InsertMachineInstrInMaps(*OrSaveExec);
+ LIS->InsertMachineInstrInMaps(*And);
LIS->InsertMachineInstrInMaps(*Xor);
LIS->InsertMachineInstrInMaps(*Branch);
+ LIS->removeInterval(SrcReg);
LIS->removeInterval(DstReg);
+ LIS->createAndComputeVirtRegInterval(SrcReg);
LIS->createAndComputeVirtRegInterval(DstReg);
LIS->createAndComputeVirtRegInterval(SaveReg);
@@ -388,8 +389,9 @@
// AND the break condition operand with exec, then OR that into the "loop
// exit" mask.
MachineInstr *And = nullptr, *Or = nullptr;
+ Register AndReg;
if (!SkipAnding) {
- Register AndReg = MRI->createVirtualRegister(BoolRC);
+ AndReg = MRI->createVirtualRegister(BoolRC);
And = BuildMI(MBB, &MI, DL, TII->get(AndOpc), AndReg)
.addReg(Exec)
.add(MI.getOperand(1));
@@ -398,8 +400,6 @@
Or = BuildMI(MBB, &MI, DL, TII->get(OrOpc), Dst)
.addReg(AndReg)
.add(MI.getOperand(2));
- if (LIS)
- LIS->createAndComputeVirtRegInterval(AndReg);
} else {
Or = BuildMI(MBB, &MI, DL, TII->get(OrOpc), Dst)
.add(MI.getOperand(1))
@@ -411,9 +411,11 @@
LV->replaceKillInstruction(MI.getOperand(2).getReg(), MI, *Or);
if (LIS) {
- if (And)
- LIS->InsertMachineInstrInMaps(*And);
LIS->ReplaceMachineInstrInMaps(MI, *Or);
+ if (And) {
+ LIS->InsertMachineInstrInMaps(*And);
+ LIS->createAndComputeVirtRegInterval(AndReg);
+ }
}
MI.eraseFromParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158141.550992.patch
Type: text/x-patch
Size: 2585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230817/fb868e5a/attachment.bin>
More information about the llvm-commits
mailing list