PR c++/68795: fix uninitialized close_paren_loc in cp_parser_postfix_expression
[gcc.git] / gcc / graphite-dependences.c
index bb81ae3ebaa159ed3c433f3eccdb13e2bce1b49c..37737da087092431d3dbd477988b06b4db435768 100644 (file)
@@ -1,5 +1,5 @@
 /* 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>.
 
@@ -37,17 +37,8 @@ along with GCC; see the file COPYING3.  If not see
 #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 *
@@ -89,8 +80,16 @@ scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs)
        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);
+             }
          }
     }
 
@@ -114,8 +113,16 @@ scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs)
        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);
+             }
          }
     }
 
@@ -139,9 +146,16 @@ scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs)
        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);
+             }
          }
     }
 
@@ -376,28 +390,32 @@ compute_deps (scop_p scop, vec<poly_bb_p> pbbs,
 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)
     {
@@ -406,6 +424,14 @@ scop_get_dependences (scop_p scop)
       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;
 }