Skip to content

Commit dc86935

Browse files
gang chensys_zuul
authored andcommitted
more work to get assume-uniform work
Change-Id: I6e51840f414c881a53e178b61d7409416e76e8ab
1 parent 2c28df8 commit dc86935

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

IGC/Compiler/CISACodeGen/WIAnalysis.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,66 +1384,65 @@ WIAnalysis::WIDependancy WIAnalysisRunner::calculate_dep(const SelectInst* inst)
13841384

13851385
bool WIAnalysisRunner::TrackAllocaDep(const Value* I, AllocaDep& dep)
13861386
{
1387+
bool trackable = true;
1388+
SmallVector<Instruction*, 4> AssumeToErase;
13871389
for (Value::const_user_iterator use_it = I->user_begin(), use_e = I->user_end(); use_it != use_e; ++use_it)
13881390
{
13891391
if (const GetElementPtrInst * gep = dyn_cast<GetElementPtrInst>(*use_it))
13901392
{
1391-
if (TrackAllocaDep(gep, dep))
1392-
continue;
1393+
trackable &= TrackAllocaDep(gep, dep);
13931394
}
1394-
if (const llvm::LoadInst * pLoad = llvm::dyn_cast<llvm::LoadInst>(*use_it))
1395+
else if (const llvm::LoadInst * pLoad = llvm::dyn_cast<llvm::LoadInst>(*use_it))
13951396
{
1396-
if (!pLoad->isSimple())
1397-
return false;
1397+
trackable &= (pLoad->isSimple());
13981398
}
13991399
else if (const llvm::StoreInst * pStore = llvm::dyn_cast<llvm::StoreInst>(*use_it))
14001400
{
1401-
if (!pStore->isSimple())
1402-
return false;
1403-
const llvm::Value* pValueOp = pStore->getValueOperand();
1404-
if (pValueOp == I)
1405-
{
1406-
// GEP instruction is the stored value of the StoreInst (not supported case)
1407-
return false;
1408-
}
1401+
trackable &= (pStore->isSimple());
1402+
// Not supported case: GEP instruction is the stored value of the StoreInst
1403+
trackable &= (pStore->getValueOperand() != I);
14091404
dep.stores.push_back(pStore);
14101405
}
14111406
else if (const llvm::BitCastInst * pBitCast = llvm::dyn_cast<llvm::BitCastInst>(*use_it))
14121407
{
1413-
if (TrackAllocaDep(pBitCast, dep))
1414-
{
1415-
continue;
1416-
}
1417-
// Not a candidate.
1418-
return false;
1408+
trackable &= TrackAllocaDep(pBitCast, dep);
1409+
}
1410+
else if (const llvm::AddrSpaceCastInst* pAddrCast = llvm::dyn_cast<llvm::AddrSpaceCastInst>(*use_it))
1411+
{
1412+
trackable &= TrackAllocaDep(pAddrCast, dep);
14191413
}
14201414
else if (const GenIntrinsicInst* intr = dyn_cast<GenIntrinsicInst>(*use_it))
14211415
{
14221416
GenISAIntrinsic::ID IID = intr->getIntrinsicID();
14231417
if (IID == GenISAIntrinsic::GenISA_assume_uniform)
14241418
{
14251419
dep.assume_uniform = true;
1426-
continue;
1420+
// remove this assume-uniform so it will not affect later pass
1421+
AssumeToErase.push_back((GenIntrinsicInst*)intr);
14271422
}
1428-
return false;
1423+
else
1424+
trackable = false;
14291425
}
14301426
else if (const IntrinsicInst * intr = dyn_cast<IntrinsicInst>(*use_it))
14311427
{
14321428
llvm::Intrinsic::ID IID = intr->getIntrinsicID();
1433-
if (IID == llvm::Intrinsic::lifetime_start ||
1434-
IID == llvm::Intrinsic::lifetime_end)
1429+
if (IID != llvm::Intrinsic::lifetime_start &&
1430+
IID != llvm::Intrinsic::lifetime_end)
14351431
{
1436-
continue;
1432+
trackable = false;
14371433
}
1438-
return false;
14391434
}
14401435
else
14411436
{
14421437
// This is some other instruction. Right now we don't want to handle these
1443-
return false;
1438+
trackable = false;
14441439
}
14451440
}
1446-
return true;
1441+
for (auto* inst : AssumeToErase)
1442+
{
1443+
inst->eraseFromParent();
1444+
}
1445+
return trackable;
14471446
}
14481447

14491448

0 commit comments

Comments
 (0)