Skip to content

Commit 7d079ed

Browse files
DianaChensys_zuul
authored andcommitted
Add analysis of stateless memory load/store
Add the analysis to StatelessToStatefull pass to check if there is non kernel argument memory load/store. Change-Id: Ieff012618efceeb637446927e9914ecf3ec5f2b6
1 parent e63aa56 commit 7d079ed

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,9 +1371,9 @@ namespace IGC
13711371
opcode == llvm_gradientYfine);
13721372
}
13731373

1374-
bool IsStatelessMemLoadIntrinsic(const llvm::GenIntrinsicInst& inst)
1374+
bool IsStatelessMemLoadIntrinsic(llvm::GenISAIntrinsic::ID id)
13751375
{
1376-
switch(inst.getIntrinsicID())
1376+
switch(id)
13771377
{
13781378
case GenISAIntrinsic::GenISA_simdBlockRead:
13791379
return true;
@@ -1383,9 +1383,9 @@ namespace IGC
13831383
return false;
13841384
}
13851385

1386-
bool IsStatelessMemStoreIntrinsic(const llvm::GenIntrinsicInst& inst)
1386+
bool IsStatelessMemStoreIntrinsic(llvm::GenISAIntrinsic::ID id)
13871387
{
1388-
switch (inst.getIntrinsicID()) {
1388+
switch (id) {
13891389
case GenISAIntrinsic::GenISA_simdBlockWrite:
13901390
return true;
13911391
default:
@@ -1394,7 +1394,7 @@ namespace IGC
13941394
return false;
13951395
}
13961396

1397-
bool IsStatelessMemAtomicIntrinsic(const llvm::GenIntrinsicInst& inst)
1397+
bool IsStatelessMemAtomicIntrinsic(GenIntrinsicInst& inst, GenISAIntrinsic::ID id)
13981398
{
13991399
// This includes:
14001400
// GenISA_intatomicraw

IGC/Compiler/CISACodeGen/helper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ namespace IGC
175175
bool IsSIMDBlockIntrinsic(llvm::Instruction* inst);
176176
bool isSubGroupIntrinsic(const llvm::Instruction* I);
177177

178-
bool IsStatelessMemLoadIntrinsic(const llvm::GenIntrinsicInst& inst);
179-
bool IsStatelessMemStoreIntrinsic(const llvm::GenIntrinsicInst& inst);
180-
bool IsStatelessMemAtomicIntrinsic(const llvm::GenIntrinsicInst& inst);
178+
bool IsStatelessMemLoadIntrinsic(llvm::GenISAIntrinsic::ID id);
179+
bool IsStatelessMemStoreIntrinsic(llvm::GenISAIntrinsic::ID id);
180+
bool IsStatelessMemAtomicIntrinsic(llvm::GenIntrinsicInst& inst, llvm::GenISAIntrinsic::ID id);
181181

182182
bool isURBWriteIntrinsic(const llvm::Instruction* inst);
183183

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStatefull/StatelessToStatefull.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,22 @@ void StatelessToStatefull::visitCallInst(CallInst& I)
604604
m_changed = true;
605605
}
606606
}
607+
// check if there's non-kernel-arg load/store
608+
if (IsStatelessMemStoreIntrinsic(intrinID) ||
609+
IsStatelessMemLoadIntrinsic(intrinID) ||
610+
IsStatelessMemAtomicIntrinsic(*Inst, intrinID)) {
611+
612+
Value* ptr = Inst->getOperand(0);
613+
if (!pointerIsFromKernelArgument(*ptr)) {
614+
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
615+
if (IsStatelessMemStoreIntrinsic(intrinID))
616+
ctx->m_hasNonKernelArgStore = true;
617+
else if (IsStatelessMemLoadIntrinsic(intrinID))
618+
ctx->m_hasNonKernelArgLoad = true;
619+
else
620+
ctx->m_hasNonKernelArgAtomic = true;
621+
}
622+
}
607623
}
608624
}
609625

@@ -652,6 +668,12 @@ void StatelessToStatefull::visitLoadInst(LoadInst& I)
652668

653669
m_changed = true;
654670
}
671+
672+
// check if there's non-kernel-arg load/store
673+
if (!pointerIsFromKernelArgument(*ptr)) {
674+
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
675+
ctx->m_hasNonKernelArgLoad = true;
676+
}
655677
}
656678

657679
void StatelessToStatefull::visitStoreInst(StoreInst& I)
@@ -693,6 +715,11 @@ void StatelessToStatefull::visitStoreInst(StoreInst& I)
693715
m_changed = true;
694716
}
695717
}
718+
719+
if (!pointerIsFromKernelArgument(*ptr)) {
720+
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
721+
ctx->m_hasNonKernelArgStore = true;
722+
}
696723
}
697724

698725
CallInst* StatelessToStatefull::createBufferPtr(unsigned addrSpace, Constant* argNumber, Instruction* InsertBefore)

0 commit comments

Comments
 (0)