[gcc/]
authorRoman Gareev <gareevroman@gmail.com>
Thu, 24 Jul 2014 14:08:29 +0000 (14:08 +0000)
committerRoman Gareev <romangareev@gcc.gnu.org>
Thu, 24 Jul 2014 14:08:29 +0000 (14:08 +0000)
* graphite-isl-ast-to-gimple.c:
(graphite_create_new_loop): Add calling of isl_id_free to properly
decrement reference counts.

[gcc/testsuite]

* gcc.dg/graphite/isl-ast-gen-blocks-4.c: New testcase.

From-SVN: r212994

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c
gcc/testsuite/gcc.dg/graphite/isl-ast-gen-blocks-4.c [new file with mode: 0644]

index cee82abe9d463b8dfaf38a6714944b1998489fe8..f1a0b3c02774dc1c37c1b0d09188d61c2e4fad2e 100644 (file)
@@ -1,3 +1,11 @@
+2014-07-24  Roman Gareev  <gareevroman@gmail.com>
+
+       * graphite-isl-ast-to-gimple.c:
+       (graphite_create_new_loop): Add calling of isl_id_free to properly
+       decrement reference counts.
+
+       * gcc.dg/graphite/isl-ast-gen-blocks-4.c: New testcase.
+
 2014-07-24  Martin Liska  <mliska@suse.cz>
 
        * cgraphunit.c (compile): Correct function used.
index b42d3317a6f3269c9c5e38031d83c6df2922cd57..77b5ed4afe18ca97bbfde42e1ebffdc07facd668 100644 (file)
@@ -389,6 +389,10 @@ graphite_create_new_loop (edge entry_edge, __isl_keep isl_ast_node *node_for,
 
   isl_ast_expr *for_iterator = isl_ast_node_for_get_iterator (node_for);
   isl_id *id = isl_ast_expr_get_id (for_iterator);
+  std::map<isl_id *, tree>::iterator res;
+  res = ip.find (id);
+  if (ip.count (id))
+    isl_id_free (res->first);
   ip[id] = iv;
   isl_ast_expr_free (for_iterator);
   return loop;
diff --git a/gcc/testsuite/gcc.dg/graphite/isl-ast-gen-blocks-4.c b/gcc/testsuite/gcc.dg/graphite/isl-ast-gen-blocks-4.c
new file mode 100644 (file)
index 0000000..36c0159
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fgraphite-identity -fgraphite-code-generator=isl" } */
+
+static int __attribute__((noinline))
+foo (int k, int n1, int n2, int n3)
+{
+  int j, res = 0;
+  for (j = 0; j < k; j++)
+    {
+      int i;
+      for (i = 0; i < n1; i++)
+        res += i;
+      for (i = 0; i < n2; i++)
+        res += i;
+      for (i = 0; i < n3; i++)
+        res += i;
+    }
+
+  return res;
+}
+
+extern void abort ();
+
+int
+main (void)
+{ 
+  int res = foo (4, 50, 50, 50);
+  if (res != 14700)
+    abort ();
+
+  return 0;
+}