@@ -45,32 +45,23 @@ bool isSupportedReduction(Halide::Internal::Stmt stmt) {
4545 return false ;
4646}
4747
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
5048// If id is the statement identifier of an update statement
5149// 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) {
5351 TC_CHECK_EQ (scop.halide .statements .count (id), 1u )
5452 << " id is not a statement in scop" << id;
5553 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);
6555}
6656
6757} // namespace
6858
6959isl::union_set reductionUpdates (isl::union_set domain, const Scop& scop) {
60+ domain = scop.body .reductions .intersect_domain (domain).domain ();
7061 auto update = isl::union_set::empty (domain.get_space ());
7162 domain.foreach_set ([&update, &scop](isl::set set) {
7263 auto setId = set.get_tuple_id ();
73- if (isReductionUpdateId (setId, scop)) {
64+ if (isSupportedReductionUpdateId (setId, scop)) {
7465 update = update.unite (set);
7566 }
7667 });
0 commit comments