Skip to content

Commit 3c718c0

Browse files
zuban32sys_zuul
authored andcommitted
Make TPM::SVMChecker consider existing genx.svm instructions
Change-Id: I3cf2f8f5a085170900f384b5ea66253d51d88912
1 parent 6374ccc commit 3c718c0

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXThreadPrivateMemory.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,43 +1028,52 @@ void SplitGather(CallInst *CI) {
10281028
}
10291029

10301030
class SVMChecker {
1031-
std::map<Value *, int> Visited;
1031+
static constexpr unsigned LoadsThreshold = 1;
1032+
1033+
std::map<Value *, unsigned> Visited;
10321034

10331035
public:
10341036
// pre-transformation analysis to determine
10351037
// which kind of mem should we place TPM at
1036-
int checkSVMNecessary(Value *V) {
1038+
unsigned checkSVMNecessary(Value *V) {
10371039
if (Visited.count(V) > 0)
10381040
return Visited.at(V);
10391041
// do not handle ConstExprs for now
10401042
if (!isa<Instruction>(V) && !isa<Argument>(V))
10411043
return 0;
1042-
int LoadsMet = 0;
1044+
unsigned LoadsMet = 0;
10431045
if (isa<LoadInst>(V)) {
10441046
++LoadsMet;
10451047
} else if (auto *CI = dyn_cast<CallInst>(V)) {
10461048
auto IID = GenXIntrinsic::getAnyIntrinsicID(CI);
10471049
if (IID == GenXIntrinsic::genx_gather_private ||
10481050
IID == GenXIntrinsic::genx_scatter_private ||
1051+
// TODO: make this analysis interprocedural
10491052
IID == GenXIntrinsic::not_any_intrinsic) {
10501053
// do not process users of priv mem intrinsics
10511054
// or calls to other functions
10521055
return 0;
1056+
} else if (IID == GenXIntrinsic::genx_svm_gather ||
1057+
IID == GenXIntrinsic::genx_svm_scatter) {
1058+
// Switch to SVM immediately once we meet some previously
1059+
// generated genx.svm intrinsics communicating with private memory
1060+
// TODO: handling svm.block_ld/st requires support from replace* and
1061+
// split* methods as well
1062+
return LoadsThreshold + 1;
10531063
}
10541064
} else if (isa<PHINode>(V) || isa<ICmpInst>(V)) {
10551065
// do not go thru phi as loops may appear and
10561066
// it doesn't seem necessary for the analysis now
10571067
return 0;
10581068
}
1059-
int Result = 0;
1060-
for (auto *U : V->users()) {
1069+
unsigned Result = 0;
1070+
for (auto *U : V->users())
10611071
Result = std::max(Result, checkSVMNecessary(U));
1062-
}
10631072
Visited.insert(std::make_pair(V, Result + LoadsMet));
10641073
return Result + LoadsMet;
10651074
}
10661075

1067-
bool operator()(Value *V) { return checkSVMNecessary(V) > 1; }
1076+
bool operator()(Value *V) { return checkSVMNecessary(V) > LoadsThreshold; }
10681077
};
10691078

10701079
void GenXThreadPrivateMemory::addUsers(Value *V) {

0 commit comments

Comments
 (0)