Skip to content

Commit 78585be

Browse files
jgu222igcbot
authored andcommitted
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.)
1 parent 8bc3ee1 commit 78585be

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,14 +1149,27 @@ bool VariableReuseAnalysis::getElementValue(
11491149

11501150
void VariableReuseAnalysis::InsertElementAliasing(Function* F)
11511151
{
1152+
// There are dead blocks that are still not removed, don't count them
1153+
// Should use F->size() once dead BBs are removed
1154+
auto getNumBBs = [](Function* aF) {
1155+
int32_t i = 1; // count entry
1156+
for (BasicBlock &aBB : aF->getBasicBlockList()) {
1157+
if (aBB.hasNPredecessors(0)) {
1158+
continue;
1159+
}
1160+
++i;
1161+
}
1162+
return i;
1163+
};
1164+
11521165
// Do it if VectorAlias != 0.
11531166
// VectorAlias=0x1: subvec aliasing for isolated values (getRootValue()=null)
11541167
// =0x2: subvec aliasing for both isolated and non-isolated value)
11551168
const auto control = (m_pCtx->getVectorCoalescingControl() & 0x3);
11561169
// To avoid increasing GRF pressure, skip if F is too large or not an entry
1157-
const uint32_t NumBBThreshold = (int)IGC_GET_FLAG_VALUE(VectorAliasBBThreshold);
1170+
const int32_t NumBBThreshold = (int)IGC_GET_FLAG_VALUE(VectorAliasBBThreshold);
11581171
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
1159-
if (control == 0 || !isEntryFunc(pMdUtils, F) || F->size() > NumBBThreshold) {
1172+
if (control == 0 || !isEntryFunc(pMdUtils, F) || getNumBBs(F) > NumBBThreshold) {
11601173
return;
11611174
}
11621175
for (auto BI = F->begin(), BE = F->end(); BI != BE; ++BI)
@@ -1715,4 +1728,4 @@ bool VariableReuseAnalysis::skipScalarAliaser(BasicBlock* BB, Value* ScalarVal)
17151728
{
17161729
Instruction* I = dyn_cast<Instruction>(ScalarVal);
17171730
return ((BB->size() > 500) || !I || I->getParent() != BB);
1718-
}
1731+
}

0 commit comments

Comments
 (0)