Skip to content

Commit 151e297

Browse files
committed
[AMDGPU] Simplify cumode handling in SIMemoryLegalizer
Differential Revision: https://reviews.llvm.org/D89663
1 parent 89d7197 commit 151e297

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ class SIMemOpAccess final {
253253
class SICacheControl {
254254
protected:
255255

256+
//// AMDGPU subtarget info.
257+
const GCNSubtarget &ST;
258+
256259
/// Instruction info.
257260
const SIInstrInfo *TII = nullptr;
258261

@@ -379,7 +382,6 @@ class SIGfx7CacheControl : public SIGfx6CacheControl {
379382

380383
class SIGfx10CacheControl : public SIGfx7CacheControl {
381384
protected:
382-
bool CuMode = false;
383385

384386
/// Sets DLC bit to "true" if present in \p MI. Returns true if \p MI
385387
/// is modified, false otherwise.
@@ -389,8 +391,7 @@ class SIGfx10CacheControl : public SIGfx7CacheControl {
389391

390392
public:
391393

392-
SIGfx10CacheControl(const GCNSubtarget &ST, bool CuMode) :
393-
SIGfx7CacheControl(ST), CuMode(CuMode) {};
394+
SIGfx10CacheControl(const GCNSubtarget &ST) : SIGfx7CacheControl(ST) {};
394395

395396
bool enableLoadCacheBypass(const MachineBasicBlock::iterator &MI,
396397
SIAtomicScope Scope,
@@ -672,7 +673,7 @@ Optional<SIMemOpInfo> SIMemOpAccess::getAtomicCmpxchgOrRmwInfo(
672673
return constructFromMIWithMMO(MI);
673674
}
674675

675-
SICacheControl::SICacheControl(const GCNSubtarget &ST) {
676+
SICacheControl::SICacheControl(const GCNSubtarget &ST) : ST(ST) {
676677
TII = ST.getInstrInfo();
677678
IV = getIsaVersion(ST.getCPU());
678679
InsertCacheInv = !AmdgcnSkipCacheInvalidations;
@@ -685,7 +686,7 @@ std::unique_ptr<SICacheControl> SICacheControl::create(const GCNSubtarget &ST) {
685686
return std::make_unique<SIGfx6CacheControl>(ST);
686687
if (Generation < AMDGPUSubtarget::GFX10)
687688
return std::make_unique<SIGfx7CacheControl>(ST);
688-
return std::make_unique<SIGfx10CacheControl>(ST, ST.isCuModeEnabled());
689+
return std::make_unique<SIGfx10CacheControl>(ST);
689690
}
690691

691692
bool SIGfx6CacheControl::enableLoadCacheBypass(
@@ -956,7 +957,7 @@ bool SIGfx10CacheControl::enableLoadCacheBypass(
956957
// the WGP. Therefore need to bypass the L0 which is per CU. Otherwise in
957958
// CU mode all waves of a work-group are on the same CU, and so the L0
958959
// does not need to be bypassed.
959-
if (!CuMode) Changed |= enableGLCBit(MI);
960+
if (!ST.isCuModeEnabled()) Changed |= enableGLCBit(MI);
960961
break;
961962
case SIAtomicScope::WAVEFRONT:
962963
case SIAtomicScope::SINGLETHREAD:
@@ -1016,7 +1017,7 @@ bool SIGfx10CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
10161017
// the WGP. Therefore need to invalidate the L0 which is per CU. Otherwise
10171018
// in CU mode and all waves of a work-group are on the same CU, and so the
10181019
// L0 does not need to be invalidated.
1019-
if (!CuMode) {
1020+
if (!ST.isCuModeEnabled()) {
10201021
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_GL0_INV));
10211022
Changed = true;
10221023
}
@@ -1076,7 +1077,7 @@ bool SIGfx10CacheControl::insertWait(MachineBasicBlock::iterator &MI,
10761077
// they are visible to waves in the other CU as the L0 is per CU.
10771078
// Otherwise in CU mode and all waves of a work-group are on the same CU
10781079
// which shares the same L0.
1079-
if (!CuMode) {
1080+
if (!ST.isCuModeEnabled()) {
10801081
if ((Op & SIMemOp::LOAD) != SIMemOp::NONE)
10811082
VMCnt |= true;
10821083
if ((Op & SIMemOp::STORE) != SIMemOp::NONE)

0 commit comments

Comments
 (0)