Simplify computation of reduction dependences
authorTobias Grosser <tobias@grosser.es>
Sun, 7 Dec 2014 22:51:45 +0000 (22:51 +0000)
committerTobias Grosser <tobias@grosser.es>
Sun, 7 Dec 2014 22:51:45 +0000 (22:51 +0000)
This simplifies the construction of the input for the reduction dependence
computation and at the same time removes an assumption that expects the schedule
to be of 2D + 1 form (the odd dimensions giving textual order, the even
dimensions the loop iterations).

llvm-svn: 223621

polly/lib/Analysis/Dependences.cpp

index 71d8780..c9cc778 100644 (file)
@@ -102,17 +102,11 @@ void Dependences::collectInfo(Scop &S, isl_union_map **Read,
         // but as we transformed the access domain we need the scattering
         // to match the new access domains, thus we need
         //   [Stmt[i0, i1] -> MemAcc_A[i0 + i1]] -> [0, i0, 2, i1, 0]
+        isl_map *Scatter = Stmt->getScattering();
+        Scatter = isl_map_apply_domain(
+            Scatter, isl_map_reverse(isl_map_domain_map(isl_map_copy(accdom))));
         accdom = isl_map_range_map(accdom);
-
-        isl_map *stmt_scatter = Stmt->getScattering();
-        isl_set *scatter_dom = isl_map_domain(isl_map_copy(accdom));
-        isl_set *scatter_ran = isl_map_range(stmt_scatter);
-        isl_map *scatter =
-            isl_map_from_domain_and_range(scatter_dom, scatter_ran);
-        for (unsigned u = 0, e = Stmt->getNumIterators(); u != e; u++)
-          scatter =
-              isl_map_equate(scatter, isl_dim_out, 2 * u + 1, isl_dim_in, u);
-        *AccessSchedule = isl_union_map_add_map(*AccessSchedule, scatter);
+        *AccessSchedule = isl_union_map_add_map(*AccessSchedule, Scatter);
       }
 
       if (MA->isRead())