@@ -353,19 +353,29 @@ namespace {
353353
354354using namespace tc ::polyhedral;
355355
356+ // Compute the dependence using the given may/must sources, sinks and kills.
357+ // Any of the inputs may be an empty (but non-null) union map.
358+ // Dependence analysis removes the cases transitively covered by a must source
359+ // or a kill.
356360isl::union_map computeDependences (
357- isl::union_map sources,
361+ isl::union_map maySources,
362+ isl::union_map mustSources,
358363 isl::union_map sinks,
364+ isl::union_map kills,
359365 isl::schedule schedule) {
360366 auto uai = isl::union_access_info (sinks);
361- uai = uai.set_may_source (sources);
367+ uai = uai.set_may_source (maySources);
368+ uai = uai.set_must_source (mustSources);
369+ uai = uai.set_kill (kills);
362370 uai = uai.set_schedule (schedule);
363371 auto flow = uai.compute_flow ();
364372 return flow.get_may_dependence ();
365373}
366374
367- // Do the simplest possible dependence analysis.
368- // Live-range reordering needs tagged access relations to be available.
375+ // Set up schedule constraints by performing the dependence analysis using
376+ // access relations from "scop". Set up callbacks in the constraints depending
377+ // on "scheduleOptions".
378+ //
369379// The domain of the constraints is intersected with "restrictDomain" if it is
370380// provided.
371381isl::schedule_constraints makeScheduleConstraints (
@@ -375,12 +385,16 @@ isl::schedule_constraints makeScheduleConstraints(
375385 auto schedule = toIslSchedule (scop.scheduleRoot ());
376386 auto firstChildNode = scop.scheduleRoot ()->child ({0 });
377387 auto reads = scop.reads .domain_factor_domain ();
378- auto writes = scop.mayWrites .domain_factor_domain ();
388+ auto mayWrites = scop.mayWrites .domain_factor_domain ();
389+ auto mustWrites = scop.mustWrites .domain_factor_domain ();
390+ auto empty = isl::union_map::empty (mustWrites.get_space ());
379391
380392 // RAW
381- auto flowDeps = computeDependences (writes, reads, schedule);
393+ auto flowDeps =
394+ computeDependences (mayWrites, mustWrites, reads, mustWrites, schedule);
382395 // WAR and WAW
383- auto falseDeps = computeDependences (writes.unite (reads), writes, schedule);
396+ auto falseDeps = computeDependences (
397+ mayWrites.unite (reads), empty, mayWrites, mustWrites, schedule);
384398
385399 auto allDeps = flowDeps.unite (falseDeps).coalesce ();
386400
0 commit comments