This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Select AGPR in PHI operand legalization
ClosedPublic

Authored by rampitec on Oct 18 2019, 4:24 PM.

Details

Summary

If a PHI defines AGPR legalize its operands to AGPR.
At the moment we can get an AGPR PHI with VGPR operands.
I am not aware of any problems as it seems to be handled
gracefully in RA, but this is not right anyway.

It also slightly decreases VGPR pressure in some cases
because we do not have to a copy via VGPR.

Diff Detail

Event Timeline

rampitec created this revision.Oct 18 2019, 4:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2019, 4:24 PM

Also note, if such PHI survives until RA, it will go into PHI elimination where it will be converted into a COPY. Then it has to be handled by the copyPhysReg(), which is a subject to register scavenging and not very efficient anyway. We have much better chances to deal with it earlier if that is a well formed PHI.

Testcase?

Probably I can forge a mir which should not have vgpr inputs for agpr result. So far I cannot figure out why a .mir dumped with -stop-before does not run the next pass (si-fix-sgpr-copies).

Testcase?

Probably I can forge a mir which should not have vgpr inputs for agpr result. So far I cannot figure out why a .mir dumped with -stop-before does not run the next pass (si-fix-sgpr-copies).

An IR testcase would also be useful for the copy behavior, it will be useful for RegBankSelect with AGPR eventually

Testcase?

Probably I can forge a mir which should not have vgpr inputs for agpr result. So far I cannot figure out why a .mir dumped with -stop-before does not run the next pass (si-fix-sgpr-copies).

An IR testcase would also be useful for the copy behavior, it will be useful for RegBankSelect with AGPR eventually

An IR testcase is in the previous patch, mfma-loop.ll. Initialization happens in the entry block, and that demonstrates the problem. I just cannot figure out how to make lit checks.

rampitec updated this revision to Diff 225920.Oct 21 2019, 10:52 AM
arsenm accepted this revision.Oct 21 2019, 12:06 PM

LGTM

This revision is now accepted and ready to land.Oct 21 2019, 12:06 PM
This revision was automatically updated to reflect the committed changes.