Skip to content

Commit

Permalink
Refactor vectoralias
Browse files Browse the repository at this point in the history
As some dead BBs are not removed in codegen emit, don't count those dead
bbs when counting the number of BBs.

Once those dead BBs are removed, should use F->size() to get the number
of BBs. (This is a temporary solution. Once the regerssion caused by adding simplifyCFG gets
resolved, this temporary solution should be removed.)
  • Loading branch information
jgu222 authored and igcbot committed Sep 3, 2024
1 parent 8bc3ee1 commit 78585be
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,14 +1149,27 @@ bool VariableReuseAnalysis::getElementValue(

void VariableReuseAnalysis::InsertElementAliasing(Function* F)
{
// There are dead blocks that are still not removed, don't count them
// Should use F->size() once dead BBs are removed
auto getNumBBs = [](Function* aF) {
int32_t i = 1; // count entry
for (BasicBlock &aBB : aF->getBasicBlockList()) {
if (aBB.hasNPredecessors(0)) {
continue;
}
++i;
}
return i;
};

// Do it if VectorAlias != 0.
// VectorAlias=0x1: subvec aliasing for isolated values (getRootValue()=null)
// =0x2: subvec aliasing for both isolated and non-isolated value)
const auto control = (m_pCtx->getVectorCoalescingControl() & 0x3);
// To avoid increasing GRF pressure, skip if F is too large or not an entry
const uint32_t NumBBThreshold = (int)IGC_GET_FLAG_VALUE(VectorAliasBBThreshold);
const int32_t NumBBThreshold = (int)IGC_GET_FLAG_VALUE(VectorAliasBBThreshold);
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
if (control == 0 || !isEntryFunc(pMdUtils, F) || F->size() > NumBBThreshold) {
if (control == 0 || !isEntryFunc(pMdUtils, F) || getNumBBs(F) > NumBBThreshold) {
return;
}
for (auto BI = F->begin(), BE = F->end(); BI != BE; ++BI)
Expand Down Expand Up @@ -1715,4 +1728,4 @@ bool VariableReuseAnalysis::skipScalarAliaser(BasicBlock* BB, Value* ScalarVal)
{
Instruction* I = dyn_cast<Instruction>(ScalarVal);
return ((BB->size() > 500) || !I || I->getParent() != BB);
}
}

0 comments on commit 78585be

Please sign in to comment.