+/* Check if the user has set acc->restrict_sources and if so
+ * intersect the range of "dep" with the result of a call to this function.
+ *
+ * Since the user expects a mapping from sink iterations to source iterations,
+ * whereas the domain of "dep" is a wrapped map, mapping sink iterations
+ * to accessed array elements, we first need to project out the accessed
+ * sink array elements by applying acc->domain_map.
+ */
+static __isl_give isl_map *restrict_sources(__isl_take isl_map *dep,
+ struct isl_access_info *acc, int source)
+{
+ isl_map *source_map;
+ isl_set *param;
+
+ if (!acc->restrict_sources)
+ return dep;
+
+ source_map = isl_map_copy(dep);
+ source_map = isl_map_apply_domain(source_map,
+ isl_map_copy(acc->domain_map));
+ param = acc->restrict_sources(source_map, acc->sink.data,
+ acc->source[source].data);
+ dep = isl_map_intersect_range(dep, param);
+ return dep;
+}
+