re PR middle-end/53849 (ICE: in add_referenced_var_1, at tree-dfa.c:567 with -O2...
authorRichard Guenther <rguenther@suse.de>
Wed, 4 Jul 2012 12:09:09 +0000 (12:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 4 Jul 2012 12:09:09 +0000 (12:09 +0000)
2012-07-04  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/53849
* tree-cfg.c (move_stmt_op): Only call add_referenced_var
for duplicated locals.  Use add_referenced_var_1 to avoid
pushing/popping cfun.

* gcc.dg/pr53849.c: New testcase.

From-SVN: r189255

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr53849.c [new file with mode: 0644]
gcc/tree-cfg.c

index b5110a6..27c8cfc 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-04  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53849
+       * tree-cfg.c (move_stmt_op): Only call add_referenced_var
+       for duplicated locals.  Use add_referenced_var_1 to avoid
+       pushing/popping cfun.
+
 2012-07-04  Kai Tietz  <ktietz@redhat.com>
 
        * config/i386/winnt.c (i386_pe_reloc_rw_mask): New function.
index 42366fa..884f66b 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-04  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53849
+       * gcc.dg/pr53849.c: New testcase.
+
 2012-07-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/53812
diff --git a/gcc/testsuite/gcc.dg/pr53849.c b/gcc/testsuite/gcc.dg/pr53849.c
new file mode 100644 (file)
index 0000000..3b67010
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fno-tree-loop-im" } */
+
+extern int *b, *e[8], d;
+
+void
+foo (void)
+{
+  int i;
+  for (i = 0; i < 8; ++i)
+    while (--d)
+      e[i] = 0;
+}
index fe5af70..dd47609 100644 (file)
@@ -6023,14 +6023,11 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
          if ((TREE_CODE (t) == VAR_DECL
               && !is_global_var (t))
              || TREE_CODE (t) == CONST_DECL)
-           replace_by_duplicate_decl (tp, p->vars_map, p->to_context);
-
-         if (SSA_VAR_P (t)
-             && gimple_in_ssa_p (cfun))
            {
-             push_cfun (DECL_STRUCT_FUNCTION (p->to_context));
-             add_referenced_var (*tp);
-             pop_cfun ();
+             struct function *to_fn = DECL_STRUCT_FUNCTION (p->to_context);
+             replace_by_duplicate_decl (tp, p->vars_map, p->to_context);
+             if (gimple_referenced_vars (to_fn))
+               add_referenced_var_1 (*tp, to_fn);
            }
        }
       *walk_subtrees = 0;