From 59cf892c758cd532b5a2ab88e6ed24eb9134659d Mon Sep 17 00:00:00 2001 From: "Dmitrichenko, Aleksei" Date: Tue, 27 Jun 2023 12:54:40 -0700 Subject: [PATCH] [Autobackout][FuncReg]Revert of change: 85781460b8348008c73e65346c4f0f38be3be56e Reuse constant vector payload for subsequent stores Reuse constant vector payload for subsequent stores when possible --- IGC/Compiler/CISACodeGen/EmitVISAPass.cpp | 42 ++--------------------- IGC/Compiler/CISACodeGen/EmitVISAPass.hpp | 10 +----- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp index 7d7b9deae85a..c0bf5d188e29 100644 --- a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp +++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp @@ -11271,7 +11271,6 @@ void EmitPass::emitStoreRawIndexed( varOffset, immOffset, pValToStore, - inst->getParent(), cacheOpts, inst->getAlignment(), false); @@ -11456,7 +11455,6 @@ void EmitPass::emitStore( varOffset, immOffset, inst->getValueOperand(), - inst->getParent(), cacheOpts, IGCLLVM::getAlignmentValue(inst), inst->getMetadata("enable.vmask")); @@ -18186,8 +18184,7 @@ void EmitPass::emitLSCVectorStore_uniform( void EmitPass::emitLSCVectorStore( Value* Ptr, Value* varOffset, ConstantInt* immOffset, - Value* storedVal, BasicBlock* BB, - LSC_CACHE_OPTS cacheOpts, alignment_t align, bool dontForceDmask) + Value* storedVal, LSC_CACHE_OPTS cacheOpts, alignment_t align, bool dontForceDmask) { PointerType* ptrType = cast(Ptr->getType()); Type* Ty = storedVal->getType(); @@ -18195,7 +18192,7 @@ void EmitPass::emitLSCVectorStore( Type* eltTy = VTy ? VTy->getElementType() : Ty; uint32_t eltBytes = GetScalarTypeSizeInRegister(eltTy); uint32_t elts = VTy ? int_cast(VTy->getNumElements()) : 1; - + CVariable* storedVar = GetSymbol(storedVal); unsigned int width = numLanes(m_currShader->m_SIMDSize); ResourceDescriptor resource = GetResourceVariable(Ptr); @@ -18227,28 +18224,6 @@ void EmitPass::emitLSCVectorStore( // when true, one simd instance is generated only! bool isOCLUniform = isUniformStoreOCL(varOffset, storedVal); - CVariable* storedVar; - - // If constant vector is stored and there is already var instance for it - // try reusing it (if it was defined in the same basic block) - // or create a new var instance and make it available for reusing in further stores - Constant* constantStoredVal = dyn_cast(storedVal); - ConstVectorStoreData* constVectorData = nullptr; - if (constantStoredVal && constantStoredVal->getType()->isVectorTy()) - { - if (!m_constantVectorStores.count(constantStoredVal) || - !(m_constantVectorStores[constantStoredVal].BB == BB)) - { - m_constantVectorStores[constantStoredVal] = {GetSymbol(storedVal), nullptr, BB}; - } - constVectorData = &m_constantVectorStores[constantStoredVal]; - storedVar = constVectorData->var; - } - else - { - storedVar = GetSymbol(storedVal); - } - // In case eOffset isn't GRF aligned, need to create a copy // For non-uniform variable, it should be already GRF-aligned. eOffset = ReAlignUniformVariable(eOffset, EALIGN_GRF); @@ -18285,18 +18260,7 @@ void EmitPass::emitLSCVectorStore( VecMessInfo.getLSCInfo(Ty, align, m_currShader->GetContext(), useA32, false); eOffset = BroadcastIfUniform(eOffset); - - // try reusing the old broadcasted data as well - if (constVectorData) - { - storedVar = constVectorData->broadcastedVar ? - constVectorData->broadcastedVar : BroadcastIfUniform(storedVar); - constVectorData->broadcastedVar = storedVar; - } - else - { - storedVar = BroadcastIfUniform(storedVar); - } + storedVar = BroadcastIfUniform(storedVar); ResourceLoop(resource, [&](CVariable* flag) { for (uint32_t i = 0; i < VecMessInfo.numInsts; ++i) diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp index 523713dc0637..b4d9a44e1f07 100644 --- a/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp +++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.hpp @@ -433,8 +433,7 @@ class EmitPass : public llvm::FunctionPass uint64_t align); void emitLSCVectorStore(llvm::Value *Ptr, llvm::Value *offset, llvm::ConstantInt *immOffset, - llvm::Value *storedVal, llvm::BasicBlock* BB, - LSC_CACHE_OPTS cacheOpts, + llvm::Value *storedVal, LSC_CACHE_OPTS cacheOpts, alignment_t align, bool dontForceDMask); void emitGenISACopy(llvm::GenIntrinsicInst* GenCopyInst); void emitUniformVectorCopy(CVariable* Dst, CVariable* Src, uint32_t nElts, @@ -957,13 +956,6 @@ class EmitPass : public llvm::FunctionPass bool m_isDuplicate; CVariable *m_tmpDest = nullptr; std::set lifetimeStartAdded; - - typedef struct { - CVariable* var; - CVariable* broadcastedVar; - llvm::BasicBlock* BB; - } ConstVectorStoreData; - llvm::DenseMap m_constantVectorStores; }; } // namespace IGC