Move to isl's new dependence analysis interface [NFC]
authorTobias Grosser <tobias@grosser.es>
Tue, 21 Apr 2015 08:47:29 +0000 (08:47 +0000)
committerTobias Grosser <tobias@grosser.es>
Tue, 21 Apr 2015 08:47:29 +0000 (08:47 +0000)
isl_union_map_compute_flow() has been replaced by
isl_union_access_info_compute_flow(). This change does not intend to
change funcitonality, yet. However, it will allow us to pass in subsequent
changes schedule trees to the dependence analysis instead of flat schedules.
This should speed up dependence analysis for important cases significantly.

llvm-svn: 235373

polly/lib/Analysis/DependenceInfo.cpp

index 8f52220e5148918235d66dcbd2286dedd2780f1c..aa52fc1b29ee7f1ad8f4abd8365ca2906190df2a 100644 (file)
@@ -241,41 +241,71 @@ void Dependences::calculateDependences(Scop &S) {
         dbgs() << "MayWrite: " << MayWrite << "\n";
         dbgs() << "Schedule: " << Schedule << "\n");
 
-  // The pointers below will be set by the subsequent calls to
-  // isl_union_map_compute_flow.
   RAW = WAW = WAR = RED = nullptr;
 
   if (OptAnalysisType == VALUE_BASED_ANALYSIS) {
-    isl_union_map_compute_flow(
-        isl_union_map_copy(Read), isl_union_map_copy(Write),
-        isl_union_map_copy(MayWrite), isl_union_map_copy(Schedule), &RAW,
-        nullptr, nullptr, nullptr);
-
-    isl_union_map_compute_flow(
-        isl_union_map_copy(Write), isl_union_map_copy(Write),
-        isl_union_map_copy(Read), isl_union_map_copy(Schedule), &WAW, &WAR,
-        nullptr, nullptr);
+    isl_union_access_info *AI;
+    isl_union_flow *Flow;
+
+    AI = isl_union_access_info_from_sink(isl_union_map_copy(Read));
+    AI = isl_union_access_info_set_must_source(AI, isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_may_source(AI, isl_union_map_copy(MayWrite));
+    AI = isl_union_access_info_set_schedule_map(AI,
+                                                isl_union_map_copy(Schedule));
+    Flow = isl_union_access_info_compute_flow(AI);
+
+    RAW = isl_union_flow_get_must_dependence(Flow);
+    isl_union_flow_free(Flow);
+
+    AI = isl_union_access_info_from_sink(isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_must_source(AI, isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_may_source(AI, isl_union_map_copy(Read));
+    AI = isl_union_access_info_set_schedule_map(AI,
+                                                isl_union_map_copy(Schedule));
+    Flow = isl_union_access_info_compute_flow(AI);
+
+    WAW = isl_union_flow_get_must_dependence(Flow);
+    WAR = isl_union_flow_get_may_dependence(Flow);
+
+    // This subtraction is needed to obtain the same results as were given by
+    // isl_union_map_compute_flow. For large sets this may add some compile-time
+    // cost. As there does not seem to be a need to distinguish between WAW and
+    // WAR, refactoring Polly to only track general non-flow dependences may
+    // improve performance.
+    WAR = isl_union_map_subtract(WAR, isl_union_map_copy(WAW));
+    isl_union_flow_free(Flow);
   } else {
-    isl_union_map *Empty;
+    isl_union_access_info *AI;
+    isl_union_flow *Flow;
 
-    Empty = isl_union_map_empty(isl_union_map_get_space(Write));
     Write = isl_union_map_union(Write, isl_union_map_copy(MayWrite));
 
-    isl_union_map_compute_flow(
-        isl_union_map_copy(Read), isl_union_map_copy(Empty),
-        isl_union_map_copy(Write), isl_union_map_copy(Schedule), nullptr, &RAW,
-        nullptr, nullptr);
-
-    isl_union_map_compute_flow(
-        isl_union_map_copy(Write), isl_union_map_copy(Empty),
-        isl_union_map_copy(Read), isl_union_map_copy(Schedule), nullptr, &WAR,
-        nullptr, nullptr);
-
-    isl_union_map_compute_flow(
-        isl_union_map_copy(Write), isl_union_map_copy(Empty),
-        isl_union_map_copy(Write), isl_union_map_copy(Schedule), nullptr, &WAW,
-        nullptr, nullptr);
-    isl_union_map_free(Empty);
+    AI = isl_union_access_info_from_sink(isl_union_map_copy(Read));
+    AI = isl_union_access_info_set_may_source(AI, isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_schedule_map(AI,
+                                                isl_union_map_copy(Schedule));
+    Flow = isl_union_access_info_compute_flow(AI);
+
+    RAW = isl_union_flow_get_may_dependence(Flow);
+    isl_union_flow_free(Flow);
+
+    AI = isl_union_access_info_from_sink(isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_may_source(AI, isl_union_map_copy(Read));
+    AI = isl_union_access_info_set_schedule_map(AI,
+                                                isl_union_map_copy(Schedule));
+    Flow = isl_union_access_info_compute_flow(AI);
+
+    WAR = isl_union_flow_get_may_dependence(Flow);
+    isl_union_flow_free(Flow);
+
+    AI = isl_union_access_info_from_sink(isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_may_source(AI, isl_union_map_copy(Write));
+    AI = isl_union_access_info_set_schedule_map(AI,
+                                                isl_union_map_copy(Schedule));
+    Flow = isl_union_access_info_compute_flow(AI);
+
+    WAW = isl_union_flow_get_may_dependence(Flow);
+    isl_union_flow_free(Flow);
   }
 
   isl_union_map_free(MayWrite);