Skip to content

Commit

Permalink
Use Vector Mask when a stateless load is a sample source
Browse files Browse the repository at this point in the history
Use Vector Mask if shader has a stateless load that contributes to a sample
coordinate value.
  • Loading branch information
mmerecki authored and igcbot committed Oct 25, 2023
1 parent c5f82fb commit 5a8d26a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 8 additions & 3 deletions IGC/Compiler/CISACodeGen/EmitVISAPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,25 @@ static bool DefReachUseWithinLevel(llvm::Value* def, const llvm::Instruction* us
return false;
}

bool EmitPass::IsNoMaskAllowed(SDAG& sdag)
bool EmitPass::IsNoMaskAllowed(Instruction* inst, const CodeGenContext* ctx)
{
if (auto* I = dyn_cast<LoadInst>(sdag.m_root))
if (auto* I = dyn_cast<LoadInst>(inst))
{
BufferType bufType = DecodeBufferType(I->getPointerAddressSpace());
return I->getPointerAddressSpace() != ADDRESS_SPACE_PRIVATE &&
I->getPointerAddressSpace() != ADDRESS_SPACE_GLOBAL &&
I->getPointerAddressSpace() != ADDRESS_SPACE_CONSTANT &&
!(bufType == CONSTANT_BUFFER && m_currShader->GetContext()->getModuleMetaData()->compOpt.WaDisableSubspanUseNoMaskForCB);
!(bufType == CONSTANT_BUFFER && ctx->getModuleMetaData()->compOpt.WaDisableSubspanUseNoMaskForCB);
}

return true;
}

bool EmitPass::IsNoMaskAllowed(SDAG& sdag) const
{
return IsNoMaskAllowed(sdag.m_root, m_currShader->GetContext());
}

uint EmitPass::DecideInstanceAndSlice(const llvm::BasicBlock& blk, SDAG& sdag, bool& slicing)
{
m_encoder->SetSubSpanDestination(false);
Expand Down
3 changes: 2 additions & 1 deletion IGC/Compiler/CISACodeGen/EmitVISAPass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ class EmitPass : public llvm::FunctionPass
template<size_t N>
void JoinSIMD(CVariable* (&tempdst)[N], uint responseLength, SIMDMode mode);
CVariable* BroadcastIfUniform(CVariable* pVar, bool nomask = false);
bool IsNoMaskAllowed(SDAG& sdag);
static bool IsNoMaskAllowed(Instruction* inst, const CodeGenContext* ctx);
bool IsNoMaskAllowed(SDAG& sdag) const;
uint DecideInstanceAndSlice(const llvm::BasicBlock& blk, SDAG& sdag, bool& slicing);
bool IsUndefOrZeroImmediate(const llvm::Value* value);
inline bool isUndefOrConstInt0(const llvm::Value* val)
Expand Down
5 changes: 3 additions & 2 deletions IGC/Compiler/CISACodeGen/PatternMatchPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,10 @@ namespace IGC
}

m_subSpanUse.insert(v);
if (LoadInst * load = dyn_cast<LoadInst>(v))

if (Instruction* inst = dyn_cast<Instruction>(v))
{
if (load->getPointerAddressSpace() == ADDRESS_SPACE_PRIVATE)
if (EmitPass::IsNoMaskAllowed(inst, m_ctx))
{
m_NeedVMask = true;
}
Expand Down

0 comments on commit 5a8d26a

Please sign in to comment.