mirror of
https://github.com/intel/intel-graphics-compiler.git
synced 2025-11-04 08:21:06 +08:00
Avoid recalculating dominator trees in PushAnalysis
Calculate dominator and post dominator trees only once per function and only when needed.
This commit is contained in:
@ -193,10 +193,6 @@ namespace IGC
|
||||
if (!llvm::isa<llvm::LoadInst>(inst))
|
||||
return false;
|
||||
|
||||
m_PDT = &getAnalysis<PostDominatorTreeWrapperPass>(*m_pFunction).getPostDomTree();
|
||||
m_DT = &getAnalysis<DominatorTreeWrapperPass>(*m_pFunction).getDomTree();
|
||||
m_entryBB = &m_pFunction->getEntryBlock();
|
||||
|
||||
// %15 = load <3 x float> addrspace(2)* %14, align 16
|
||||
llvm::LoadInst* pLoad = llvm::cast<llvm::LoadInst>(inst);
|
||||
uint address_space = pLoad->getPointerAddressSpace();
|
||||
@ -372,7 +368,7 @@ namespace IGC
|
||||
llvm::Instruction* inst,
|
||||
llvm::Value* pAddress,
|
||||
int& pushableAddressGrfOffset,
|
||||
int& pushableOffsetGrfOffset) const
|
||||
int& pushableOffsetGrfOffset)
|
||||
{
|
||||
// skip casts
|
||||
while (
|
||||
@ -449,8 +445,16 @@ namespace IGC
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PushAnalysis::IsSafeToPushNonStaticBufferLoad(llvm::Instruction* inst) const
|
||||
bool PushAnalysis::IsSafeToPushNonStaticBufferLoad(llvm::Instruction* inst)
|
||||
{
|
||||
if (!m_PDT)
|
||||
{
|
||||
m_PDT = &getAnalysis<PostDominatorTreeWrapperPass>(*m_pFunction).getPostDomTree();
|
||||
}
|
||||
if (!m_DT)
|
||||
{
|
||||
m_DT = &getAnalysis<DominatorTreeWrapperPass>(*m_pFunction).getDomTree();
|
||||
}
|
||||
// Find the return BB or the return BB before discard lowering.
|
||||
bool searchForRetBBBeforeDiscard = false;
|
||||
BasicBlock* retBB = m_PDT->getRootNode()->getBlock();
|
||||
@ -741,7 +745,7 @@ namespace IGC
|
||||
m_context->platform.getWATable().Wa_16011983264 &&
|
||||
m_context->type == ShaderType::HULL_SHADER)
|
||||
{
|
||||
Function* URBReadFunction = GenISAIntrinsic::getDeclaration(m_module, GenISAIntrinsic::GenISA_URBRead);
|
||||
Function* URBReadFunction = GenISAIntrinsic::getDeclaration(m_pFunction->getParent(), GenISAIntrinsic::GenISA_URBRead);
|
||||
if (GetMaxNumberOfPushedInputs() == 0 ||
|
||||
none_of(URBReadFunction->users(), [](const User* user) { return isa<GenIntrinsicInst>(user); }))
|
||||
{
|
||||
@ -987,7 +991,6 @@ namespace IGC
|
||||
std::min(m_pullConstantHeuristics->getPushConstantThreshold(m_pFunction) * getMinPushConstantBufferAlignmentInBytes(),
|
||||
(maxPushedGRFs - largestIndex) * getGRFSize());
|
||||
unsigned int sizePushed = 0;
|
||||
m_entryBB = &m_pFunction->getEntryBlock();
|
||||
|
||||
// Runtime values are changed to intrinsics. So we need to do it before.
|
||||
for (auto bb = m_pFunction->begin(), be = m_pFunction->end(); bb != be; ++bb)
|
||||
|
||||
@ -42,12 +42,10 @@ namespace IGC
|
||||
bool m_funcTypeChanged;
|
||||
std::map <llvm::Function*, bool> m_isFuncTypeChanged;
|
||||
|
||||
llvm::Module* m_module;
|
||||
llvm::Function* m_pFunction;
|
||||
IGCMD::MetaDataUtils* m_pMdUtils;
|
||||
llvm::PostDominatorTree* m_PDT;
|
||||
llvm::DominatorTree* m_DT;
|
||||
llvm::BasicBlock* m_entryBB;
|
||||
|
||||
PullConstantHeuristics* m_pullConstantHeuristics;
|
||||
|
||||
@ -75,7 +73,7 @@ namespace IGC
|
||||
SimplePushInfo& info);
|
||||
|
||||
/// Checks if stateless buffer load is not under flow control.
|
||||
bool IsSafeToPushNonStaticBufferLoad(llvm::Instruction* inst) const;
|
||||
bool IsSafeToPushNonStaticBufferLoad(llvm::Instruction* inst);
|
||||
|
||||
// Checks if pAddress is a RuntimeValue and is on the list of pushable
|
||||
// runtime values.
|
||||
@ -83,7 +81,7 @@ namespace IGC
|
||||
llvm::Instruction* inst,
|
||||
llvm::Value* pAddress,
|
||||
int& pushableAddressGrfOffset,
|
||||
int& pushableOffsetGrfOffset) const;
|
||||
int& pushableOffsetGrfOffset);
|
||||
|
||||
bool GetConstantOffsetForDynamicUniformBuffer(
|
||||
llvm::Value* offsetValue,
|
||||
@ -158,7 +156,8 @@ namespace IGC
|
||||
void AnalyzeFunction(llvm::Function* F)
|
||||
{
|
||||
m_pFunction = F;
|
||||
m_module = F->getParent();
|
||||
m_PDT = nullptr;
|
||||
m_DT = nullptr;
|
||||
|
||||
// We need to initialize m_argIndex and m_argList appropriately as there might be some arguments added before push analysis stage
|
||||
m_argIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user