-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[AMDGPU]: Add support to unpack V_PK_MOV_B32 #163464
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
Open
akadutta
wants to merge
11
commits into
llvm:main
Choose a base branch
from
akadutta:users/akadutta/amdgpu/v_pk_mov_b32_unpack
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+667
−91
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dc0089e
add support for v_pk_mov unpacking, redundant code removal, bug fixes
akadutta 8587628
restoring deleted assert
akadutta 27affd8
Merge branch 'main' into users/akadutta/amdgpu/v_pk_mov_b32_unpack
akadutta 25b9c71
Update test with suggestion
akadutta e2fbe0c
Apply suggestion from @arsenm
akadutta 08fdc07
Apply suggestion from @arsenm
akadutta 44b3744
reduce code size, address code reviews
akadutta 75daff0
Apply suggestion from @arsenm
akadutta 53009ee
code optimization, clang-format
akadutta 4089361
Merge branch 'users/akadutta/amdgpu/v_pk_mov_b32_unpack' of https://g…
akadutta 6b43f6c
add removed test, remove func liveins in test
akadutta 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 |
|---|---|---|
|
|
@@ -615,11 +615,12 @@ void SIPreEmitPeephole::collectUnpackingCandidates( | |
| for (auto I = std::next(BeginMI.getIterator()); I != E; ++I) { | ||
| MachineInstr &Instr = *I; | ||
| uint16_t UnpackedOpCode = mapToUnpackedOpcode(Instr); | ||
| bool IsUnpackable = | ||
| !(UnpackedOpCode == std::numeric_limits<uint16_t>::max()); | ||
akadutta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (Instr.isMetaInstruction()) | ||
| continue; | ||
| if ((Instr.isTerminator()) || | ||
| (TII->isNeverCoissue(Instr) && | ||
| (UnpackedOpCode == std::numeric_limits<uint16_t>::max())) || | ||
| (TII->isNeverCoissue(Instr) && !IsUnpackable) || | ||
| (SIInstrInfo::modifiesModeRegister(Instr) && | ||
| Instr.modifiesRegister(AMDGPU::EXEC, TRI))) | ||
| return; | ||
|
|
@@ -643,7 +644,7 @@ void SIPreEmitPeephole::collectUnpackingCandidates( | |
| if (TRI->regsOverlap(MFMADef, InstrMO.getReg())) | ||
| return; | ||
| } | ||
| if (UnpackedOpCode == std::numeric_limits<uint16_t>::max()) | ||
| if (!IsUnpackable) | ||
| continue; | ||
|
|
||
| if (canUnpackingClobberRegister(Instr)) | ||
|
|
@@ -822,24 +823,26 @@ bool SIPreEmitPeephole::run(MachineFunction &MF) { | |
|
|
||
| // TODO: Fold this into previous block, if possible. Evaluate and handle any | ||
| // side effects. | ||
| if (ST.hasGFX950Insts() || ST.hasGFX940Insts()) { | ||
| for (MachineBasicBlock &MBB : MF) { | ||
| // Unpack packed instructions overlapped by MFMAs. This allows the | ||
| // compiler to co-issue unpacked instructions with MFMA | ||
| auto SchedModel = TII->getSchedModel(); | ||
| SetVector<MachineInstr *> InstrsToUnpack; | ||
| for (auto &MI : make_early_inc_range(MBB.instrs())) { | ||
| if (!SIInstrInfo::isMFMA(MI)) | ||
| continue; | ||
| const MCSchedClassDesc *SchedClassDesc = | ||
| SchedModel.resolveSchedClass(&MI); | ||
| uint16_t NumMFMACycles = | ||
| SchedModel.getWriteProcResBegin(SchedClassDesc)->ReleaseAtCycle; | ||
| collectUnpackingCandidates(MI, InstrsToUnpack, NumMFMACycles); | ||
| } | ||
| for (MachineInstr *MI : InstrsToUnpack) { | ||
| performF32Unpacking(*MI); | ||
| } | ||
|
|
||
| // Perform the extra MF scans only for supported archs | ||
| if (!ST.hasGFX940Insts()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another unrelated simplification you can recommit |
||
| return Changed; | ||
| for (MachineBasicBlock &MBB : MF) { | ||
| // Unpack packed instructions overlapped by MFMAs. This allows the | ||
| // compiler to co-issue unpacked instructions with MFMA | ||
| auto SchedModel = TII->getSchedModel(); | ||
| SetVector<MachineInstr *> InstrsToUnpack; | ||
| for (auto &MI : make_early_inc_range(MBB.instrs())) { | ||
| if (!SIInstrInfo::isMFMA(MI)) | ||
| continue; | ||
| const MCSchedClassDesc *SchedClassDesc = | ||
| SchedModel.resolveSchedClass(&MI); | ||
| uint16_t NumMFMACycles = | ||
| SchedModel.getWriteProcResBegin(SchedClassDesc)->ReleaseAtCycle; | ||
| collectUnpackingCandidates(MI, InstrsToUnpack, NumMFMACycles); | ||
| } | ||
| for (MachineInstr *MI : InstrsToUnpack) { | ||
| performF32Unpacking(*MI); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
You are viewing a condensed version of this merge commit. You can view the full changes here.
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.
I don't know why it's written this way, but you're making a set of redundant conditions worse. The mapToUnpackedOpcode call should be sunk and supersedes all of the other checks here (e.g., why is ib bothering checking isTerminator?)
Not sure what any of this has to do with adding the new case