Skip to content

Commit 4f18eca

Browse files
Gang Y Chenigcbot
authored andcommitted
Insert VectorUniform at the nearest dominator of all stores
1 parent 4bc6b44 commit 4f18eca

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ class TransposeHelperPromote : public TransposeHelper
526526
StoreInst* pStore,
527527
Value* pScalarizedIdx);
528528
AllocaInst* pVecAlloca;
529+
std::set<BasicBlock*> StoreBBs; // location of all stores
529530
TransposeHelperPromote(AllocaInst* pAI) : TransposeHelper(false) { pVecAlloca = pAI; }
530531
};
531532

@@ -551,7 +552,16 @@ void LowerGEPForPrivMem::handleAllocaInst(llvm::AllocaInst* pAlloca)
551552
// to keep the promoted vector as uniform in the next round of WIAnalysis
552553
bool isUniformAlloca = pAlloca->getMetadata("uniform") != nullptr;
553554
if (isUniformAlloca && pAlloca->getAllocatedType()->isArrayTy()) {
554-
IRBuilder<> IRB1(pAlloca);
555+
BasicBlock* CommonDomBB = nullptr;
556+
for (auto* SB : helper.StoreBBs)
557+
{
558+
if (!CommonDomBB)
559+
CommonDomBB = SB;
560+
else
561+
CommonDomBB = m_DT->findNearestCommonDominator(CommonDomBB, SB);
562+
}
563+
assert(CommonDomBB);
564+
IRBuilder<> IRB1(CommonDomBB->getFirstNonPHI());
555565
auto pVecF = GenISAIntrinsic::getDeclaration(m_pFunc->getParent(),
556566
GenISAIntrinsic::GenISA_vectorUniform, pVecAlloca->getAllocatedType());
557567
auto pVecInit = IRB1.CreateCall(pVecF);
@@ -710,10 +720,11 @@ void TransposeHelperPromote::handleStoreInst(
710720
llvm::StoreInst* pStore,
711721
llvm::Value* pScalarizedIdx)
712722
{
713-
// Add Store instruction to remove list
714723
IGC_ASSERT(nullptr != pStore);
715724
IGC_ASSERT(pStore->isSimple());
716-
725+
// remember the location of the stores in order to
726+
// compute the nearest dominator
727+
StoreBBs.insert(pStore->getParent());
717728
IRBuilder<> IRB(pStore);
718729
llvm::Value* pStoreVal = pStore->getValueOperand();
719730
llvm::Value* pLoadVecAlloca = IRB.CreateLoad(pVecAlloca);

0 commit comments

Comments
 (0)