@@ -1028,43 +1028,52 @@ void SplitGather(CallInst *CI) {
1028
1028
}
1029
1029
1030
1030
class SVMChecker {
1031
- std::map<Value *, int > Visited;
1031
+ static constexpr unsigned LoadsThreshold = 1 ;
1032
+
1033
+ std::map<Value *, unsigned > Visited;
1032
1034
1033
1035
public:
1034
1036
// pre-transformation analysis to determine
1035
1037
// which kind of mem should we place TPM at
1036
- int checkSVMNecessary (Value *V) {
1038
+ unsigned checkSVMNecessary (Value *V) {
1037
1039
if (Visited.count (V) > 0 )
1038
1040
return Visited.at (V);
1039
1041
// do not handle ConstExprs for now
1040
1042
if (!isa<Instruction>(V) && !isa<Argument>(V))
1041
1043
return 0 ;
1042
- int LoadsMet = 0 ;
1044
+ unsigned LoadsMet = 0 ;
1043
1045
if (isa<LoadInst>(V)) {
1044
1046
++LoadsMet;
1045
1047
} else if (auto *CI = dyn_cast<CallInst>(V)) {
1046
1048
auto IID = GenXIntrinsic::getAnyIntrinsicID (CI);
1047
1049
if (IID == GenXIntrinsic::genx_gather_private ||
1048
1050
IID == GenXIntrinsic::genx_scatter_private ||
1051
+ // TODO: make this analysis interprocedural
1049
1052
IID == GenXIntrinsic::not_any_intrinsic) {
1050
1053
// do not process users of priv mem intrinsics
1051
1054
// or calls to other functions
1052
1055
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 ;
1053
1063
}
1054
1064
} else if (isa<PHINode>(V) || isa<ICmpInst>(V)) {
1055
1065
// do not go thru phi as loops may appear and
1056
1066
// it doesn't seem necessary for the analysis now
1057
1067
return 0 ;
1058
1068
}
1059
- int Result = 0 ;
1060
- for (auto *U : V->users ()) {
1069
+ unsigned Result = 0 ;
1070
+ for (auto *U : V->users ())
1061
1071
Result = std::max (Result, checkSVMNecessary (U));
1062
- }
1063
1072
Visited.insert (std::make_pair (V, Result + LoadsMet));
1064
1073
return Result + LoadsMet;
1065
1074
}
1066
1075
1067
- bool operator ()(Value *V) { return checkSVMNecessary (V) > 1 ; }
1076
+ bool operator ()(Value *V) { return checkSVMNecessary (V) > LoadsThreshold ; }
1068
1077
};
1069
1078
1070
1079
void GenXThreadPrivateMemory::addUsers (Value *V) {
0 commit comments