@@ -45,32 +45,23 @@ bool isSupportedReduction(Halide::Internal::Stmt stmt) {
45
45
return false ;
46
46
}
47
47
48
- // TODO: the function currently available in Scop only works _after_ inserting
49
- // the reduction. that is a kind of internal state dependence we want to avoid
50
48
// If id is the statement identifier of an update statement
51
49
// of a supported type of reduction, then return true.
52
- bool isReductionUpdateId (isl::id id, const Scop& scop) {
50
+ bool isSupportedReductionUpdateId (isl::id id, const Scop& scop) {
53
51
TC_CHECK_EQ (scop.halide .statements .count (id), 1u )
54
52
<< " id is not a statement in scop" << id;
55
53
auto provideNode = scop.halide .statements .at (id);
56
- if (!isSupportedReduction (provideNode)) {
57
- return false ;
58
- }
59
- for (auto const & iup : scop.halide .reductions ) {
60
- if (iup.update .same_as (provideNode)) {
61
- return true ;
62
- }
63
- }
64
- return false ;
54
+ return isSupportedReduction (provideNode);
65
55
}
66
56
67
57
} // namespace
68
58
69
59
isl::union_set reductionUpdates (isl::union_set domain, const Scop& scop) {
60
+ domain = scop.body .reductions .intersect_domain (domain).domain ();
70
61
auto update = isl::union_set::empty (domain.get_space ());
71
62
domain.foreach_set ([&update, &scop](isl::set set) {
72
63
auto setId = set.get_tuple_id ();
73
- if (isReductionUpdateId (setId, scop)) {
64
+ if (isSupportedReductionUpdateId (setId, scop)) {
74
65
update = update.unite (set);
75
66
}
76
67
});
0 commit comments