/* Data dependence analysis for Graphite.
- Copyright (C) 2009-2015 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@amd.com> and
Konrad Trifunovic <konrad.trifunovic@inria.fr>.
#include "tree-pass.h"
#include "cfgloop.h"
#include "tree-data-ref.h"
-
-#include <isl/constraint.h>
-#include <isl/set.h>
-#include <isl/map.h>
-#include <isl/union_map.h>
-#include <isl/flow.h>
-#include <isl/constraint.h>
-
#include "graphite.h"
-
/* Add the constraints from the set S to the domain of MAP. */
static isl_map *
if (pdr_read_p (pdr))
{
if (dump_file)
- print_pdr (dump_file, pdr);
+ {
+ fprintf (dump_file, "Adding read to depedence graph: ");
+ print_pdr (dump_file, pdr);
+ }
res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
+ if (dump_file)
+ {
+ fprintf (dump_file, "Reads depedence graph: ");
+ print_isl_union_map (dump_file, res);
+ }
}
}
if (pdr_write_p (pdr))
{
if (dump_file)
- print_pdr (dump_file, pdr);
+ {
+ fprintf (dump_file, "Adding must write to depedence graph: ");
+ print_pdr (dump_file, pdr);
+ }
res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
+ if (dump_file)
+ {
+ fprintf (dump_file, "Must writes depedence graph: ");
+ print_isl_union_map (dump_file, res);
+ }
}
}
if (pdr_may_write_p (pdr))
{
if (dump_file)
- print_pdr (dump_file, pdr);
-
+ {
+ fprintf (dump_file, "Adding may write to depedence graph: ");
+ print_pdr (dump_file, pdr);
+ }
res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
+ if (dump_file)
+ {
+ fprintf (dump_file, "May writes depedence graph: ");
+ print_isl_union_map (dump_file, res);
+ }
}
}
isl_union_map *
scop_get_dependences (scop_p scop)
{
- isl_union_map *dependences;
-
- if (!scop->must_raw)
- compute_deps (scop, scop->pbbs,
- &scop->must_raw, &scop->may_raw,
- &scop->must_raw_no_source, &scop->may_raw_no_source,
- &scop->must_war, &scop->may_war,
- &scop->must_war_no_source, &scop->may_war_no_source,
- &scop->must_waw, &scop->may_waw,
- &scop->must_waw_no_source, &scop->may_waw_no_source);
-
- dependences = isl_union_map_copy (scop->must_raw);
- dependences = isl_union_map_union (dependences,
- isl_union_map_copy (scop->must_war));
- dependences = isl_union_map_union (dependences,
- isl_union_map_copy (scop->must_waw));
- dependences = isl_union_map_union (dependences,
- isl_union_map_copy (scop->may_raw));
- dependences = isl_union_map_union (dependences,
- isl_union_map_copy (scop->may_war));
- dependences = isl_union_map_union (dependences,
- isl_union_map_copy (scop->may_waw));
+ if (scop->dependence)
+ return scop->dependence;
+
+ /* The original dependence relations:
+ RAW are read after write dependences,
+ WAR are write after read dependences,
+ WAW are write after write dependences. */
+ isl_union_map *must_raw = NULL, *may_raw = NULL, *must_raw_no_source = NULL,
+ *may_raw_no_source = NULL, *must_war = NULL, *may_war = NULL,
+ *must_war_no_source = NULL, *may_war_no_source = NULL, *must_waw = NULL,
+ *may_waw = NULL, *must_waw_no_source = NULL, *may_waw_no_source = NULL;
+
+ compute_deps (scop, scop->pbbs,
+ &must_raw, &may_raw,
+ &must_raw_no_source, &may_raw_no_source,
+ &must_war, &may_war,
+ &must_war_no_source, &may_war_no_source,
+ &must_waw, &may_waw,
+ &must_waw_no_source, &may_waw_no_source);
+
+ isl_union_map *dependences = must_raw;
+ dependences = isl_union_map_union (dependences, must_war);
+ dependences = isl_union_map_union (dependences, must_waw);
+ dependences = isl_union_map_union (dependences, may_raw);
+ dependences = isl_union_map_union (dependences, may_war);
+ dependences = isl_union_map_union (dependences, may_waw);
if (dump_file)
{
fprintf (dump_file, ")\n");
}
+ isl_union_map_free (must_raw_no_source);
+ isl_union_map_free (may_raw_no_source);
+ isl_union_map_free (must_war_no_source);
+ isl_union_map_free (may_war_no_source);
+ isl_union_map_free (must_waw_no_source);
+ isl_union_map_free (may_waw_no_source);
+
+ scop->dependence = dependences;
return dependences;
}