This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][GFX908] IndirectCopyToAGPR: Confirm modified register is dst reg of accvgpr_write
ClosedPublic

Authored by jrbyrnes on May 4 2023, 10:09 AM.

Details

Summary

IndirectCopyToAGPR should be reworked as to avoid optimizing during copy lowering. However, as it stands, the code is buggy. This patch replaces the call to definesRegister with modifiesRegister, and confirms that the dest reg of the found accvgpr_write is in fact the src reg of our copy.

Diff Detail

Event Timeline

jrbyrnes created this revision.May 4 2023, 10:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 10:09 AM
jrbyrnes requested review of this revision.May 4 2023, 10:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 10:09 AM
arsenm added inline comments.May 12 2023, 6:28 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
591

This would be illegal, a def always must be a register

llvm/test/CodeGen/AMDGPU/accvgpr-copy.mir
926–929

Should precommit this test to show the diff here

1005

Extra whitespace change

jrbyrnes updated this revision to Diff 521694.May 12 2023, 9:49 AM

Remove redundant check + rebase on top of precommit test.

The test shows that indirectCopyToAGPR has incorrectly determined that (at the time of COPY agpr1_agpr2) we can use vgpr0 as having the same bits as agpr1 AND agpr2 (in reality, of the two, it is only consistent with agpr1). We incorrectly make the determination by our assumption of what "definesRegister" means.

arsenm added inline comments.May 12 2023, 10:14 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
589–590

This comment is also stating the obvious

591

The assert is also redundant, getReg does that for you

llvm/test/CodeGen/AMDGPU/accvgpr-copy.mir
1005

Still extra whitespace change

jrbyrnes updated this revision to Diff 521707.May 12 2023, 10:30 AM
jrbyrnes marked 6 inline comments as done.

Address comments

arsenm accepted this revision.May 12 2023, 10:45 AM
This revision is now accepted and ready to land.May 12 2023, 10:45 AM
This revision was landed with ongoing or failed builds.May 12 2023, 12:59 PM
This revision was automatically updated to reflect the committed changes.