Skip to content

Commit 14d1ba3

Browse files
YuriPlyakhinigcbot
authored andcommitted
Address feedback for predicated load/store
Address feedback from the previous patch for predicated load/store. Also disable promotion to predicated load/store, when StatelessToStatefull optimization is enabled.
1 parent 0bc0af4 commit 14d1ba3

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19576,6 +19576,7 @@ void EmitPass::emitLSCVectorLoad_subDW(LSC_CACHE_OPTS CacheOpts, bool UseA32,
1957619576
finalPredicate = IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads) ? GetCombinedVMaskPred(flag) : flag;
1957719577

1957819578
if (inputPredicate && finalPredicate) {
19579+
m_pCtx->EmitError("Predicated load is not expected.", nullptr);
1957919580
IGC_ASSERT_MESSAGE(false, "Not expected scenario. Predicated load should not be used.");
1958019581
m_encoder->And(finalPredicate, finalPredicate, inputPredicate);
1958119582
m_encoder->Push();
@@ -19763,7 +19764,7 @@ void EmitPass::emitLSCVectorLoad(Instruction* inst,
1976319764
eOffset = TruncatePointer(eOffset);
1976419765
}
1976519766

19766-
// if the merge value is dead after predicated load and is not immidiate, and
19767+
// if the merge value is dead after predicated load and is not immediate, and
1976719768
// has other properties same as destination -> use it as destination
1976819769
bool isDestReplacedWithMerge = false;
1976919770
CVariable* mergeVar = nullptr;
@@ -19912,6 +19913,7 @@ void EmitPass::emitLSCVectorLoad(Instruction* inst,
1991219913
if(predicatedLoad) {
1991319914
CVariable* cond = GetSymbol(inst->getOperand(2));
1991419915
if (pred) {
19916+
m_pCtx->EmitError("Predicated load is not expected.", inst);
1991519917
IGC_ASSERT_MESSAGE(false, "Not expected scenario. Predicated load should not be used.");
1991619918
m_encoder->And(pred, pred, cond);
1991719919
m_encoder->Push();
@@ -20018,7 +20020,10 @@ void EmitPass::emitLSCVectorStore_subDW(LSC_CACHE_OPTS CacheOpts, bool UseA32,
2001820020
// setPredicateForDiscard used earlier is used only when compiler needs to create the
2001920021
// resource loop, which is never expected for simple LLVM store or PredicatedStore.
2002020022
// Hence, these predicates should never be used together.
20021-
IGC_ASSERT_MESSAGE(doUniformStore || flag == nullptr, "Unexpected scenario: resource loop with predicated store!");
20023+
if(!doUniformStore && flag != nullptr) {
20024+
m_pCtx->EmitError("Predicated store is not expected.", nullptr);
20025+
IGC_ASSERT_MESSAGE(false, "Unexpected scenario: resource loop with predicated store!");
20026+
}
2002220027
m_encoder->SetPredicate(GetSymbol(predicate));
2002320028
}
2002420029

@@ -20286,7 +20291,10 @@ void EmitPass::emitLSCVectorStore(Value *Ptr,
2028620291
// setPredicateForDiscard used earlier is used only when compiler needs to create the
2028720292
// resource loop, which is never expected for simple LLVM store or PredicatedStore.
2028820293
// Hence, these predicates should never be used together.
20289-
IGC_ASSERT_MESSAGE(flag == nullptr, "Unexpected scenario: resource loop with predicated store!");
20294+
if (flag != nullptr) {
20295+
m_pCtx->EmitError("Predicated store is not expected.", nullptr);
20296+
IGC_ASSERT_MESSAGE(false, "Unexpected scenario: resource loop with predicated store!");
20297+
}
2029020298
m_encoder->SetPredicate(GetSymbol(predicate));
2029120299
}
2029220300

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,6 @@ static void UpdateInstTypeHint(CodeGenContext& ctx)
411411
// forward declaration
412412
llvm::ModulePass* createPruneUnusedArgumentsPass();
413413

414-
static bool useStatelessToStateful(CodeGenContext& ctx)
415-
{
416-
return (ctx.m_instrTypes.hasLoadStore &&
417-
ctx.m_DriverInfo.SupportsStatelessToStatefulBufferTransformation() &&
418-
!ctx.getModuleMetaData()->compOpt.GreaterThan4GBBufferRequired &&
419-
IGC_IS_FLAG_ENABLED(EnableStatelessToStateful) &&
420-
!ctx.m_instrTypes.hasInlineAsmPointerAccess);
421-
}
422-
423414
void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature* pSignature)
424415
{
425416
COMPILER_TIME_START(&ctx, TIME_CG_Add_Legalization_Passes);
@@ -802,7 +793,7 @@ void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSignature
802793
}
803794
}
804795

805-
if (!isOptDisabled && useStatelessToStateful(ctx))
796+
if (!isOptDisabled && ctx.useStatelessToStateful())
806797
{
807798
mpm.add(new StatelessToStateful(TargetAddressing::BINDFUL));
808799
}
@@ -1510,7 +1501,7 @@ void OptimizeIR(CodeGenContext* const pContext)
15101501
bool runGEPLSR = IGC_IS_FLAG_ENABLED(EnableGEPLSR) &&
15111502
pContext->type == ShaderType::OPENCL_SHADER &&
15121503
pContext->platform.getPlatformInfo().eProductFamily == IGFX_PVC &&
1513-
!useStatelessToStateful(*pContext) &&
1504+
!pContext->useStatelessToStateful() &&
15141505
pContext->m_retryManager.IsFirstTry();
15151506

15161507
if (runGEPLSR && IGC_IS_FLAG_DISABLED(RunGEPLSRAfterLICM))

IGC/Compiler/CodeGenPublic.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,15 @@ namespace IGC
12971297
{
12981298
return (mscratchSpaceUsedBySpills > m_spillAllowed);
12991299
}
1300+
1301+
bool useStatelessToStateful()
1302+
{
1303+
return (m_instrTypes.hasLoadStore &&
1304+
m_DriverInfo.SupportsStatelessToStatefulBufferTransformation() &&
1305+
!getModuleMetaData()->compOpt.GreaterThan4GBBufferRequired &&
1306+
IGC_IS_FLAG_ENABLED(EnableStatelessToStateful) &&
1307+
!m_instrTypes.hasInlineAsmPointerAccess);
1308+
}
13001309
};
13011310

13021311
struct SComputeShaderSecondCompileInput

IGC/Compiler/Optimizer/PromoteToPredicatedMemoryAccess.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ namespace IGC {
4747

4848
bool PromoteToPredicatedMemoryAccess::runOnFunction(Function &F) {
4949
CodeGenContext* pCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
50-
if (!pCtx->platform.hasLSC() || !pCtx->platform.LSCEnabled() ||
51-
(pCtx->type == ShaderType::OPENCL_SHADER && static_cast<OpenCLProgramContext*>(pCtx)->m_InternalOptions.PromoteStatelessToBindless))
50+
if (!pCtx->platform.hasLSC() ||
51+
!pCtx->platform.LSCEnabled() ||
52+
(pCtx->type == ShaderType::OPENCL_SHADER &&
53+
static_cast<OpenCLProgramContext*>(pCtx)->m_InternalOptions.PromoteStatelessToBindless) ||
54+
pCtx->useStatelessToStateful())
5255
return false;
5356

5457
SmallVector<std::pair<BranchInst *, bool>, 8> WorkList;

0 commit comments

Comments
 (0)