-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AMDGPU] Classify FLAT instructions as VMEM #137148
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2420,29 +2420,29 @@ bool SchedGroup::canAddMI(const MachineInstr &MI) const { | |
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::VMEM) != SchedGroupMask::NONE) && | ||
| (TII->isVMEM(MI) || (TII->isFLAT(MI) && !TII->isDS(MI)))) | ||
| TII->isVMEM(MI)) | ||
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::VMEM_READ) != SchedGroupMask::NONE) && | ||
| MI.mayLoad() && | ||
| (TII->isVMEM(MI) || (TII->isFLAT(MI) && !TII->isDS(MI)))) | ||
| TII->isVMEM(MI)) | ||
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::VMEM_WRITE) != SchedGroupMask::NONE) && | ||
| MI.mayStore() && | ||
| (TII->isVMEM(MI) || (TII->isFLAT(MI) && !TII->isDS(MI)))) | ||
| TII->isVMEM(MI)) | ||
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::DS) != SchedGroupMask::NONE) && | ||
| TII->isDS(MI)) | ||
| (TII->isDS(MI) || TII->isLDSDMA(MI))) | ||
|
||
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::DS_READ) != SchedGroupMask::NONE) && | ||
| MI.mayLoad() && TII->isDS(MI)) | ||
| MI.mayLoad() && (TII->isDS(MI) || TII->isLDSDMA(MI))) | ||
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::DS_WRITE) != SchedGroupMask::NONE) && | ||
| MI.mayStore() && TII->isDS(MI)) | ||
| MI.mayStore() && (TII->isDS(MI) || TII->isLDSDMA(MI))) | ||
| Result = true; | ||
|
|
||
| else if (((SGMask & SchedGroupMask::TRANS) != SchedGroupMask::NONE) && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,8 +168,8 @@ static const unsigned instrsForExtendedCounterTypes[NUM_EXTENDED_INST_CNTS] = { | |
| AMDGPU::S_WAIT_KMCNT}; | ||
|
|
||
| static bool updateVMCntOnly(const MachineInstr &Inst) { | ||
| return SIInstrInfo::isVMEM(Inst) || SIInstrInfo::isFLATGlobal(Inst) || | ||
| SIInstrInfo::isFLATScratch(Inst); | ||
| return (SIInstrInfo::isVMEM(Inst) && !SIInstrInfo::isFLAT(Inst)) || | ||
| SIInstrInfo::isFLATGlobal(Inst) || SIInstrInfo::isFLATScratch(Inst); | ||
| } | ||
|
|
||
| #ifndef NDEBUG | ||
|
|
@@ -695,14 +695,14 @@ class SIInsertWaitcnts { | |
| #endif // NDEBUG | ||
| } | ||
|
|
||
| // Return the appropriate VMEM_*_ACCESS type for Inst, which must be a VMEM or | ||
| // FLAT instruction. | ||
| // Return the appropriate VMEM_*_ACCESS type for Inst, which must be a VMEM | ||
| // instruction. | ||
| WaitEventType getVmemWaitEventType(const MachineInstr &Inst) const { | ||
| // Maps VMEM access types to their corresponding WaitEventType. | ||
| static const WaitEventType VmemReadMapping[NUM_VMEM_TYPES] = { | ||
| VMEM_READ_ACCESS, VMEM_SAMPLER_READ_ACCESS, VMEM_BVH_READ_ACCESS}; | ||
|
|
||
| assert(SIInstrInfo::isVMEM(Inst) || SIInstrInfo::isFLAT(Inst)); | ||
| assert(SIInstrInfo::isVMEM(Inst)); | ||
| // LDS DMA loads are also stores, but on the LDS side. On the VMEM side | ||
| // these should use VM_CNT. | ||
| if (!ST->hasVscnt() || SIInstrInfo::mayWriteLDSThroughDMA(Inst)) | ||
|
|
@@ -2454,8 +2454,8 @@ bool SIInsertWaitcnts::isPreheaderToFlush( | |
| } | ||
|
|
||
| bool SIInsertWaitcnts::isVMEMOrFlatVMEM(const MachineInstr &MI) const { | ||
| return SIInstrInfo::isVMEM(MI) || | ||
| (SIInstrInfo::isFLAT(MI) && mayAccessVMEMThroughFlat(MI)); | ||
| return (SIInstrInfo::isFLAT(MI) && mayAccessVMEMThroughFlat(MI)) || | ||
| SIInstrInfo::isVMEM(MI); | ||
|
||
| } | ||
|
|
||
| // Return true if it is better to flush the vmcnt counter in the preheader of | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -630,20 +630,29 @@ body: | | |
| ; CHECK-LABEL: name: flat_global_load | ||
| ; CHECK: liveins: $vgpr0_vgpr1 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| ; CHECK-NEXT: $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ; CHECK-NEXT: BUNDLE implicit-def $vgpr2, implicit-def $vgpr2_lo16, implicit-def $vgpr2_hi16, implicit-def $vgpr3, implicit-def $vgpr3_lo16, implicit-def $vgpr3_hi16, implicit $vgpr0_vgpr1, implicit $exec, implicit $flat_scr { | ||
| ; CHECK-NEXT: S_CLAUSE 1 | ||
| ; CHECK-NEXT: $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| ; CHECK-NEXT: $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ; CHECK-NEXT: } | ||
|
||
| ; | ||
| ; GFX11-LABEL: name: flat_global_load | ||
| ; GFX11: liveins: $vgpr0_vgpr1 | ||
| ; GFX11-NEXT: {{ $}} | ||
| ; GFX11-NEXT: $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX11-NEXT: $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX11-NEXT: BUNDLE implicit-def $vgpr2, implicit-def $vgpr2_lo16, implicit-def $vgpr2_hi16, implicit-def $vgpr3, implicit-def $vgpr3_lo16, implicit-def $vgpr3_hi16, implicit $vgpr0_vgpr1, implicit $exec, implicit $flat_scr { | ||
| ; GFX11-NEXT: S_CLAUSE 1 | ||
| ; GFX11-NEXT: $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX11-NEXT: $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX11-NEXT: } | ||
| ; | ||
| ; GFX12-LABEL: name: flat_global_load | ||
| ; GFX12: liveins: $vgpr0_vgpr1 | ||
| ; GFX12-NEXT: {{ $}} | ||
| ; GFX12-NEXT: $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX12-NEXT: $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX12-NEXT: BUNDLE implicit-def $vgpr2, implicit-def $vgpr2_lo16, implicit-def $vgpr2_hi16, implicit-def $vgpr3, implicit-def $vgpr3_lo16, implicit-def $vgpr3_hi16, implicit $vgpr0_vgpr1, implicit $exec, implicit $flat_scr { | ||
| ; GFX12-NEXT: S_CLAUSE 1 | ||
| ; GFX12-NEXT: $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX12-NEXT: $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ; GFX12-NEXT: } | ||
| $vgpr2 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
| $vgpr3 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 4, 0, implicit $exec, implicit $flat_scr | ||
| ... | ||
|
|
||
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.
Am I right in thinking that the isDS test was redundant, since no instructions are both FLAT and DS? @kerbowa
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.
Otherwise, it should check for
!isLDSDMAif we specifically want to avoid DS accesses, I think