Skip to content

Commit 26db67b

Browse files
krystian-andrzejewskiigcbot
authored andcommitted
Use V_MASK in dynamic extract element instructions in a subspan chain
This change is to use V_MASK as a predicate for indirect move instruction.
1 parent 3ea5f6b commit 26db67b

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4713,11 +4713,11 @@ CVariable* EmitPass::GetCombinedVMaskPred(CVariable* basePredicate)
47134713
return basePredicate;
47144714

47154715
bool subspan = m_encoder->IsSubSpanDestination();
4716-
if ((IGC_IS_FLAG_ENABLED(UseVMaskPredicate) || IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads)) &&
4716+
if ((IGC_IS_FLAG_ENABLED(UseVMaskPredicate) || IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads) || IGC_IS_FLAG_ENABLED(UseVMaskPredicateForIndirectMove)) &&
47174717
subspan && !m_destination->IsUniform())
47184718
{
47194719
CVariable* vmaskPredicate = m_vMaskPredForSubplane;
4720-
if (IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads))
4720+
if (IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads) || IGC_IS_FLAG_ENABLED(UseVMaskPredicateForIndirectMove))
47214721
{
47224722
vmaskPredicate = m_currShader->GetNewVariable(
47234723
numLanes(m_SimdMode),
@@ -9995,9 +9995,15 @@ void EmitPass::emitExtract(llvm::Instruction* inst)
99959995
m_encoder->Push();
99969996

99979997
dstAlias[i] = m_currShader->GetNewAlias(m_destination, m_destination->GetType(), (dstNElts / 2) * vecTypeSize * i, dstNElts / 2);
9998+
CVariable* predicate = IGC_IS_FLAG_ENABLED(UseVMaskPredicateForIndirectMove) ? GetCombinedVMaskPred() : nullptr;
9999+
999810000
// finally, we move the indirectly addressed values to the destination register
999910001
m_encoder->SetMask(i == 0 ? EMASK_H1 : EMASK_H2);
1000010002
m_encoder->SetSimdSize(SIMDMode::SIMD16);
10003+
10004+
// to avoid out-of-bounds indirect access (exceeding the maximum number of GRFs)
10005+
m_encoder->SetPredicate(predicate);
10006+
1000110007
m_encoder->Copy(dstAlias[i], pDstArrElm);
1000210008
m_encoder->Push();
1000310009
}
@@ -10016,6 +10022,9 @@ void EmitPass::emitExtract(llvm::Instruction* inst)
1001610022
m_encoder->AddrAdd(pDstArrElm, vector, pOffset3);
1001710023
m_encoder->Push();
1001810024

10025+
// to avoid out-of-bounds indirect access (exceeding the maximum number of GRFs)
10026+
m_encoder->SetPredicate(IGC_IS_FLAG_ENABLED(UseVMaskPredicateForIndirectMove) ? GetCombinedVMaskPred() : nullptr);
10027+
1001910028
// finally, we move the indirectly addressed values to the destination register
1002010029
m_encoder->Copy(m_destination, pDstArrElm);
1002110030
m_encoder->Push();
@@ -18118,7 +18127,7 @@ void EmitPass::emitLSCVectorLoad_subDW(LSC_CACHE_OPTS CacheOpts, bool UseA32,
1811818127
if (doUniformLoad)
1811918128
m_encoder->SetNoMask();
1812018129
else
18121-
m_encoder->SetPredicate(GetCombinedVMaskPred(flag));
18130+
m_encoder->SetPredicate(IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads) ? GetCombinedVMaskPred(flag) : flag);
1812218131

1812318132
emitLSCLoad(CacheOpts, gatherDst,
1812418133
eOffset, EltBytes * 8, 1, 0, &Resource, AddrSize,
@@ -18361,7 +18370,7 @@ void EmitPass::emitLSCVectorLoad(Instruction* inst,
1836118370
dVisaTy, (uint16_t)eltOffBytes, (uint16_t)nbelts);
1836218371
}
1836318372

18364-
m_encoder->SetPredicate(GetCombinedVMaskPred(flag));
18373+
m_encoder->SetPredicate(IGC_IS_FLAG_ENABLED(UseVMaskPredicateForLoads) ? GetCombinedVMaskPred(flag) : flag);
1836518374

1836618375
VectorMessage::MESSAGE_KIND messageType = VecMessInfo.insts[i].kind;
1836718376
IGC_ASSERT_MESSAGE(

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class EmitPass : public llvm::FunctionPass
375375
CVariable* GetVMaskPred(CVariable*& predicate);
376376
void createVMaskPred(CVariable*& predicate);
377377
void UseVMaskPred();
378-
CVariable* GetCombinedVMaskPred(CVariable* basePredicate);
378+
CVariable* GetCombinedVMaskPred(CVariable* basePredicate = nullptr);
379379
CVariable* m_vMaskPredForSubplane = nullptr;
380380

381381
void emitGradientX(const SSource& source, const DstModifier& modifier);

IGC/common/igc_flags.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ DECLARE_IGC_REGKEY(bool, NoCatchAllDebugLine, false, "Don't emit speci
424424
DECLARE_IGC_REGKEY(bool, EnableTestSplitI64, false, "Test legalization that split i64 store unnecessarily, to be deleted once test is done[temp]", true)
425425
DECLARE_IGC_REGKEY(bool, ShaderDumpTranslationOnly, false, "Dump LLVM IR right after translation from SPIRV to stderr and ignore all passes", false)
426426
DECLARE_IGC_REGKEY(bool, UseVMaskPredicate, false, "Use VMask as predicate for subspan usage", false)
427-
DECLARE_IGC_REGKEY(bool, UseVMaskPredicateForLoads, true, "Use VMask as predicate for subspan usage (loads only)", true)
427+
DECLARE_IGC_REGKEY(bool, UseVMaskPredicateForLoads, true, "Use VMask as predicate for subspan usage (loads only)", true)
428+
DECLARE_IGC_REGKEY(bool, UseVMaskPredicateForIndirectMove, true, "Use VMask as predicate for subspan usage (indirect mov only)", true)
428429
DECLARE_IGC_REGKEY(bool, StackOverflowDetection, false, "Inserts checks for stack overflow when stack calls are used.", true)
429430

430431
DECLARE_IGC_GROUP("IGC Features")

0 commit comments

Comments
 (0)