Skip to content

Commit 8d70ae8

Browse files
scottp101sys_zuul
authored andcommitted
extend the MarkReadOnlyPass to mark loads with constant
address space with invariant.load. Change-Id: I9f0028fe571e65ea58b3e949798299341187c481
1 parent be47a20 commit 8d70ae8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

IGC/Compiler/Optimizer/MarkReadOnlyLoad.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,36 @@ bool MarkReadOnlyLoad::runOnFunction(Function& F)
106106

107107
void MarkReadOnlyLoad::visitLoadInst(LoadInst& LI)
108108
{
109-
Value* ldPtr = LI.getPointerOperand();
110109
bool isRO = false;
111110

112-
Value* srcPtr = TracePointerSource(ldPtr);
113-
if (srcPtr && isa<GenIntrinsicInst>(srcPtr))
111+
if (LI.getPointerAddressSpace() == ADDRESS_SPACE_CONSTANT)
114112
{
115-
unsigned bufId;
116-
BufferType bufTy;
117-
BufferAccessType accTy;
118-
bool needBufferOffset; // Unused
119-
120-
// check whether we are doing read only access on buffer (e.g. on UAV)
121-
if (GetResourcePointerInfo(srcPtr, bufId, bufTy, accTy, needBufferOffset))
113+
isRO = true;
114+
}
115+
else if (auto *srcPtr = TracePointerSource(LI.getPointerOperand()))
116+
{
117+
if (isa<GenIntrinsicInst>(srcPtr))
122118
{
123-
if (accTy == BufferAccessType::ACCESS_READ)
119+
unsigned bufId;
120+
BufferType bufTy;
121+
BufferAccessType accTy;
122+
bool needBufferOffset; // Unused
123+
124+
// check whether we are doing read only access on buffer (e.g. on UAV)
125+
if (GetResourcePointerInfo(
126+
srcPtr, bufId, bufTy, accTy, needBufferOffset))
124127
{
125-
isRO = true;
128+
if (accTy == BufferAccessType::ACCESS_READ)
129+
{
130+
isRO = true;
131+
}
126132
}
127133
}
128134
}
129135

130136
if (isRO)
131137
{
138+
m_changed = true;
132139
LI.setMetadata(LLVMContext::MD_invariant_load, m_mdNode);
133140
}
134141
}

0 commit comments

Comments
 (0)