Refactor vectoralias

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.)
This commit is contained in:
Gu, Junjie
2024-09-01 15:03:01 +00:00
committed by igcbot
parent 8bc3ee1268
commit 78585be334

View File

@ -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)
@ -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);
}
}