summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-propagate.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-09-26 18:19:55 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-09-26 18:19:55 +0200
commit2186081438d522d8266dae13e9640447b7ad6189 (patch)
tree1703d97374f453dce244795360190c541f24f0af /gcc/tree-ssa-propagate.c
parent12b03642cb027437f4a0eddac8c7fd7849bfe149 (diff)
downloadgcc-2186081438d522d8266dae13e9640447b7ad6189.tar.gz
gimple-fold.c (gimplify_and_update_call_from_tree): Set gctx.into_ssa after push_gimplify_context.
* gimple-fold.c (gimplify_and_update_call_from_tree): Set gctx.into_ssa after push_gimplify_context. * gimple.c (gimple_build_call_valist): New function. * gimple.h (gimple_build_call_valist): New prototype. * tree-ssa-propagate.c (finish_update_gimple_call): New function. (update_gimple_call): Likewise. (update_call_from_tree): Use finish_update_gimple_call. * tree-ssa-propagate.h (update_gimple_call): New prototype. From-SVN: r179204
Diffstat (limited to 'gcc/tree-ssa-propagate.c')
-rw-r--r--gcc/tree-ssa-propagate.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 7741db88686..05abaa58549 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1,5 +1,5 @@
/* Generic SSA value propagation engine.
- Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
@@ -673,6 +673,40 @@ move_ssa_defining_stmt_for_defs (gimple new_stmt, gimple old_stmt)
}
}
+/* Helper function for update_gimple_call and update_call_from_tree.
+ A GIMPLE_CALL STMT is being replaced with GIMPLE_CALL NEW_STMT. */
+
+static void
+finish_update_gimple_call (gimple_stmt_iterator *si_p, gimple new_stmt,
+ gimple stmt)
+{
+ gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt));
+ move_ssa_defining_stmt_for_defs (new_stmt, stmt);
+ gimple_set_vuse (new_stmt, gimple_vuse (stmt));
+ gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+ gimple_set_location (new_stmt, gimple_location (stmt));
+ if (gimple_block (new_stmt) == NULL_TREE)
+ gimple_set_block (new_stmt, gimple_block (stmt));
+ gsi_replace (si_p, new_stmt, false);
+}
+
+/* Update a GIMPLE_CALL statement at iterator *SI_P to call to FN
+ with number of arguments NARGS, where the arguments in GIMPLE form
+ follow NARGS argument. */
+
+bool
+update_gimple_call (gimple_stmt_iterator *si_p, tree fn, int nargs, ...)
+{
+ va_list ap;
+ gimple new_stmt, stmt = gsi_stmt (*si_p);
+
+ gcc_assert (is_gimple_call (stmt));
+ va_start (ap, nargs);
+ new_stmt = gimple_build_call_valist (fn, nargs, ap);
+ finish_update_gimple_call (si_p, new_stmt, stmt);
+ va_end (ap);
+ return true;
+}
/* Update a GIMPLE_CALL statement at iterator *SI_P to reflect the
value of EXPR, which is expected to be the result of folding the
@@ -689,14 +723,8 @@ move_ssa_defining_stmt_for_defs (gimple new_stmt, gimple old_stmt)
bool
update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
{
- tree lhs;
-
gimple stmt = gsi_stmt (*si_p);
- gcc_assert (is_gimple_call (stmt));
-
- lhs = gimple_call_lhs (stmt);
-
if (valid_gimple_call_p (expr))
{
/* The call has simplified to another call. */
@@ -716,18 +744,14 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
}
new_stmt = gimple_build_call_vec (fn, args);
- gimple_call_set_lhs (new_stmt, lhs);
- move_ssa_defining_stmt_for_defs (new_stmt, stmt);
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
- gimple_set_location (new_stmt, gimple_location (stmt));
- gsi_replace (si_p, new_stmt, false);
+ finish_update_gimple_call (si_p, new_stmt, stmt);
VEC_free (tree, heap, args);
return true;
}
else if (valid_gimple_rhs_p (expr))
{
+ tree lhs = gimple_call_lhs (stmt);
gimple new_stmt;
/* The call has simplified to an expression