This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix propagate_tree_value_into_stmt
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 20 Apr 2012 13:55:08 +0200 (CEST)
- Subject: [PATCH] Fix propagate_tree_value_into_stmt
Which should properly care for updating VOPs.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
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.
Index: gcc/tree-ssa-copy.c
===================================================================
--- gcc/tree-ssa-copy.c (revision 186619)
+++ gcc/tree-ssa-copy.c (working copy)
@@ -257,13 +257,11 @@ propagate_tree_value_into_stmt (gimple_s
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);
Index: gcc/testsuite/g++.dg/torture/20120420-1.C
===================================================================
--- gcc/testsuite/g++.dg/torture/20120420-1.C (revision 0)
+++ gcc/testsuite/g++.dg/torture/20120420-1.C (revision 0)
@@ -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;
+ }
+}