-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[AMDGPU] Fix AGPR_32 reg assign for mfma scale ops #168964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+17
−8
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1c2072f
[AMDGPU] Fix AGPR_32 reg assign for mfma scale ops
hjagasiaAMD d9405f2
Check operand constraints and update mir checks.
hjagasiaAMD 92cc4c8
Merge branch 'main' into agpr-copy-mfma
hjagasiaAMD 08fc310
Get the static constraint of the known operand.
hjagasiaAMD aff0f88
Update llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp
hjagasiaAMD 1fc74ea
Update llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp
hjagasiaAMD ef61605
Update llvm/test/CodeGen/AMDGPU/rewrite-vgpr-mfma-scale-to-agpr.mir
hjagasiaAMD a55eace
Format
hjagasiaAMD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,8 +97,8 @@ class AMDGPURewriteAGPRCopyMFMAImpl { | |
|
|
||
| /// Compute the register class constraints based on the uses of \p Reg, | ||
| /// excluding MFMA uses from which can be rewritten to change the register | ||
| /// class constraint. This should be nearly identical to | ||
| /// MachineRegisterInfo::recomputeRegClass. | ||
| /// class constraint. MFMA scale operands need to be constraint checked. | ||
| /// This should be nearly identical to MachineRegisterInfo::recomputeRegClass. | ||
|
|
||
| /// \p RewriteCandidates will collect the set of MFMA instructions that need | ||
| /// to have the opcode mutated to perform the replacement. | ||
|
|
@@ -152,9 +152,26 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::recomputeRegClassExceptRewritable( | |
|
|
||
| // We can swap the classes of dst + src2 as a pair to AGPR, so ignore the | ||
| // effects of rewrite candidates. It just so happens that we can use | ||
| // either AGPR or VGPR in src0/src1, so don't bother checking the | ||
| // constraint effects of the individual operands. | ||
| // either AGPR or VGPR in src0/src1. We still need to check constraint | ||
| // effects for scale variant, which does not allow AGPR. | ||
| if (isRewriteCandidate(*MI)) { | ||
|
|
||
| int AGPROp = AMDGPU::getMFMASrcCVDstAGPROp(MI->getOpcode()); | ||
| MachineInstrBuilder TmpMIB = | ||
| BuildMI(*MI->getParent(), MI->getIterator(), MI->getDebugLoc(), | ||
| TII.get(AGPROp)); | ||
| for (const MachineOperand &TmpMO : MI->operands()) | ||
| TmpMIB.add(TmpMO); | ||
| MachineInstr *TmpMI = TmpMIB.getInstr(); | ||
| unsigned OpNo = &MO - &MI->getOperand(0); | ||
| const TargetRegisterClass *EquivalentAGPRRegClass = | ||
| TRI.getEquivalentAGPRClass(MRI.getRegClass(Reg)); | ||
| const TargetRegisterClass *Allowed = TmpMI->getRegClassConstraintEffect( | ||
|
||
| OpNo, EquivalentAGPRRegClass, &TII, &TRI); | ||
| TmpMI->eraseFromParent(); | ||
| if (!Allowed || Allowed != EquivalentAGPRRegClass) | ||
| return false; | ||
|
|
||
| const MachineOperand *VDst = | ||
| TII.getNamedOperand(*MI, AMDGPU::OpName::vdst); | ||
| const MachineOperand *Src2 = | ||
|
|
||
10 changes: 6 additions & 4 deletions
10
llvm/test/CodeGen/AMDGPU/rewrite-vgpr-mfma-scale-to-agpr.mir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely should not be creating temporary instructions