Skip to content

Commit

Permalink
AMDGPU: Always reserve VGPR for AGPR copies on gfx908
Browse files Browse the repository at this point in the history
Just because there aren't AGPRs in the original program doesn't mean
the register allocator can't choose to use them (unless we were to
forcibly reserve all AGPRs if there weren't any uses). This happens in
high pressure situations and introduces copies to avoid spills.

In this test, the allocator ends up introducing a copy from SGPR to
AGPR which requires an intermediate VGPR. I don't believe it would
introduce a copy from AGPR to AGPR in this situation, since it would
be trying to use an intermediate with a different class.

Theoretically this is also broken on gfx90a, but I have been unable to
come up with a testcase.
  • Loading branch information
arsenm committed Feb 16, 2022
1 parent 6e2cf33 commit 3884cb9
Show file tree
Hide file tree
Showing 4 changed files with 857 additions and 33 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
Expand Up @@ -622,7 +622,7 @@ BitVector SIRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
} else
MaxNumAGPRs = 0;
}
} else if (ST.hasMAIInsts() && MFI->usesAGPRs(MF)) {
} else if (ST.hasMAIInsts()) {
// In order to guarantee copying between AGPRs, we need a scratch VGPR
// available at all times.
reserveRegisterTuples(Reserved, AMDGPU::VGPR32);
Expand Down

0 comments on commit 3884cb9

Please sign in to comment.