From 5a8d26adaa8c7bca77f5824d11a27a7bca7b4ed2 Mon Sep 17 00:00:00 2001 From: Mariusz Merecki Date: Tue, 24 Oct 2023 06:18:49 +0000 Subject: [PATCH] Use Vector Mask when a stateless load is a sample source Use Vector Mask if shader has a stateless load that contributes to a sample coordinate value. --- IGC/Compiler/CISACodeGen/EmitVISAPass.cpp | 11 ++++++++--- IGC/Compiler/CISACodeGen/EmitVISAPass.hpp | 3 ++- IGC/Compiler/CISACodeGen/PatternMatchPass.cpp | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp index e8c7176c8816..6cd1fe7b15ba 100644 --- a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp +++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp @@ -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(sdag.m_root)) + if (auto* I = dyn_cast(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); diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp index 30aac6934ed3..19a83ad98a9a 100644 --- a/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp +++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp @@ -622,7 +622,8 @@ class EmitPass : public llvm::FunctionPass template 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) diff --git a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp index 1ce365ac1013..fdbe2bf5d9ed 100644 --- a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp +++ b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp @@ -1079,9 +1079,10 @@ namespace IGC } m_subSpanUse.insert(v); - if (LoadInst * load = dyn_cast(v)) + + if (Instruction* inst = dyn_cast(v)) { - if (load->getPointerAddressSpace() == ADDRESS_SPACE_PRIVATE) + if (EmitPass::IsNoMaskAllowed(inst, m_ctx)) { m_NeedVMask = true; }