tree-ssa-copy.c (propagate_tree_value_into_stmt): Use update_call_from_tree when...
authorRichard Guenther <rguenther@suse.de>
Fri, 20 Apr 2012 11:56:33 +0000 (11:56 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Apr 2012 11:56:33 +0000 (11:56 +0000)
2012-04-20  Richard Guenther  <rguenther@suse.de>

* tree-ssa-copy.c (propagate_tree_value_into_stmt): Use
update_call_from_tree when propagating into a call.

* g++.dg/torture/20120420-1.C: New testcase.

From-SVN: r186622

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/20120420-1.C [new file with mode: 0644]
gcc/tree-ssa-copy.c

index 33ef4a77f669bc4de52774ba1432b795f85f9cb1..68593c90b8c200a8c307a30b02b3b5a00b05253f 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-20  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-copy.c (propagate_tree_value_into_stmt): Use
+       update_call_from_tree when propagating into a call.
+
 2012-04-20  Alan Modra  <amodra@gmail.com>
 
        * config/rs6000/rs6000.c (rs6000_emit_savres_rtx): Formatting.
index 2faaaa59390a58ba922803c77ab8ac30c2fb0a5b..1cfffd8e7f7ae9bf632fe869d2aaa8d9bf7754f6 100644 (file)
@@ -1,3 +1,7 @@
+2012-04-20  Richard Guenther  <rguenther@suse.de>
+
+       * g++.dg/torture/20120420-1.C: New testcase.
+
 2012-04-19  Steven Bosscher  <steven@gcc.gnu.org>
 
        * gcc.target/i386/pr45830.c: Update scan-tree-dump.
diff --git a/gcc/testsuite/g++.dg/torture/20120420-1.C b/gcc/testsuite/g++.dg/torture/20120420-1.C
new file mode 100644 (file)
index 0000000..ada0ab6
--- /dev/null
@@ -0,0 +1,29 @@
+// { dg-do compile }
+
+int g, *gp[100];
+struct V {
+    int* x;
+    int y;
+};
+
+void foo (V **p, V* end, int i)
+{
+  *p = 0;
+  V* pp = *p;
+  int s = 100;
+  for (; pp < end; )
+    {
+      pp++;
+      (pp-1)->x = &g;
+      if (g)
+       {
+         if (g>10)
+           g++;
+         int *t = (int*) operator new (100);
+         (pp-1)->x = t;
+       }
+      else
+       s--;
+      gp[end-pp] = (pp-1)->x + s;
+    }
+}
index 4c6d9927bbd23c8f72cc9530ef1ae6c94f886199..45b5c92c99973075c24c0ff119a213c67155a84c 100644 (file)
@@ -257,13 +257,11 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
   else if (is_gimple_call (stmt)
            && gimple_call_lhs (stmt) != NULL_TREE)
     {
-      gimple new_stmt;
-
       tree expr = NULL_TREE;
+      bool res;
       propagate_tree_value (&expr, val);
-      new_stmt = gimple_build_assign (gimple_call_lhs (stmt), expr);
-      move_ssa_defining_stmt_for_defs (new_stmt, stmt);
-      gsi_replace (gsi, new_stmt, false);
+      res = update_call_from_tree (gsi, expr);
+      gcc_assert (res);
     }
   else if (gimple_code (stmt) == GIMPLE_SWITCH)
     propagate_tree_value (gimple_switch_index_ptr (stmt), val);