Skip to content

Commit

Permalink
[AMDGPU] Update more live intervals in SIWholeQuadMode
Browse files Browse the repository at this point in the history
This fixes various assertion failures that would otherwise be triggered
by a later patch to move SIWholeQuadMode later in the pass pipeline.

Differential Revision: https://reviews.llvm.org/D82190

Change-Id: I265ebff525c5fb9d69171762a7a6a4b82c8a5f28
  • Loading branch information
jayfoad authored and perlfu committed Jun 25, 2020
1 parent dd854f0 commit 15b32a1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,18 +1318,23 @@ void SIWholeQuadMode::processBlock(MachineBasicBlock &MBB, bool isEntry) {
if (State == StateWWM) {
assert(SavedNonWWMReg);
fromWWM(MBB, Before, SavedNonWWMReg, NonWWMState);
LIS->createAndComputeVirtRegInterval(SavedNonWWMReg);
SavedNonWWMReg = 0;
State = NonWWMState;
}

if (Needs == StateWWM) {
NonWWMState = State;
assert(!SavedNonWWMReg);
SavedNonWWMReg = MRI->createVirtualRegister(BoolRC);
toWWM(MBB, Before, SavedNonWWMReg);
State = StateWWM;
} else {
if (State == StateWQM && (Needs & StateExact) && !(Needs & StateWQM)) {
if (!WQMFromExec && (OutNeeds & StateWQM))
if (!WQMFromExec && (OutNeeds & StateWQM)) {
assert(!SavedWQMReg);
SavedWQMReg = MRI->createVirtualRegister(BoolRC);
}

toExact(MBB, Before, SavedWQMReg, findLiveMaskReg(MBB, BI, Before));
State = StateExact;
Expand Down Expand Up @@ -1363,6 +1368,8 @@ void SIWholeQuadMode::processBlock(MachineBasicBlock &MBB, bool isEntry) {

II = Next;
}
assert(!SavedWQMReg);
assert(!SavedNonWWMReg);
}

bool SIWholeQuadMode::lowerLiveMaskQueries(unsigned LiveMaskReg) {
Expand Down Expand Up @@ -1479,10 +1486,11 @@ bool SIWholeQuadMode::runOnMachineFunction(MachineFunction &MF) {

if ((GlobalFlags == StateWQM) && DemoteInstrs.empty()) {
// Shader only needs WQM
BuildMI(Entry, EntryMI, DebugLoc(), TII->get(ST->isWave32() ?
auto MI = BuildMI(Entry, EntryMI, DebugLoc(), TII->get(ST->isWave32() ?
AMDGPU::S_WQM_B32 : AMDGPU::S_WQM_B64),
Exec)
.addReg(Exec);
LIS->InsertMachineInstrInMaps(*MI);

lowerLiveMaskQueries(LiveMaskReg);
lowerCopyInstrs();
Expand Down Expand Up @@ -1520,5 +1528,10 @@ bool SIWholeQuadMode::runOnMachineFunction(MachineFunction &MF) {
lowerDemoteInstrs();
}

// Physical registers like SCC aren't tracked by default anyway, so just
// removing the ranges we computed is the simplest option for maintaining
// the analysis results.
LIS->removeRegUnit(*MCRegUnitIterator(AMDGPU::SCC, TRI));

return true;
}

0 comments on commit 15b32a1

Please sign in to comment.