aboutsummaryrefslogtreecommitdiff
path: root/gcc
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
parent12b03642cb027437f4a0eddac8c7fd7849bfe149 (diff)
downloadgcc-2186081438d522d8266dae13e9640447b7ad6189.zip
gcc-2186081438d522d8266dae13e9640447b7ad6189.tar.gz
gcc-2186081438d522d8266dae13e9640447b7ad6189.tar.bz2
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')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/gimple-fold.c1
-rw-r--r--gcc/gimple.c27
-rw-r--r--gcc/gimple.h1
-rw-r--r--gcc/tree-ssa-propagate.c50
-rw-r--r--gcc/tree-ssa-propagate.h4
6 files changed, 78 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 899ffe0..49e56ed 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2011-09-26 Jakub Jelinek <jakub@redhat.com>
+
+ * 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.
+
2011-09-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50472
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index d754ea9..e345058 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -551,6 +551,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
reaching_vuse = gimple_vuse (stmt);
push_gimplify_context (&gctx);
+ gctx.into_ssa = gimple_in_ssa_p (cfun);
if (lhs == NULL_TREE)
{
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 75885bb..9b8e1b1 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -215,9 +215,10 @@ gimple_call_reset_alias_info (gimple s)
pt_solution_reset (gimple_call_clobber_set (s));
}
-/* Helper for gimple_build_call, gimple_build_call_vec and
- gimple_build_call_from_tree. Build the basic components of a
- GIMPLE_CALL statement to function FN with NARGS arguments. */
+/* Helper for gimple_build_call, gimple_build_call_valist,
+ gimple_build_call_vec and gimple_build_call_from_tree. Build the basic
+ components of a GIMPLE_CALL statement to function FN with NARGS
+ arguments. */
static inline gimple
gimple_build_call_1 (tree fn, unsigned nargs)
@@ -272,6 +273,26 @@ gimple_build_call (tree fn, unsigned nargs, ...)
}
+/* Build a GIMPLE_CALL statement to function FN. NARGS is the number of
+ arguments. AP contains the arguments. */
+
+gimple
+gimple_build_call_valist (tree fn, unsigned nargs, va_list ap)
+{
+ gimple call;
+ unsigned i;
+
+ gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
+
+ call = gimple_build_call_1 (fn, nargs);
+
+ for (i = 0; i < nargs; i++)
+ gimple_call_set_arg (call, i, va_arg (ap, tree));
+
+ return call;
+}
+
+
/* Helper for gimple_build_call_internal and gimple_build_call_internal_vec.
Build the basic components of a GIMPLE_CALL statement to internal
function FN with NARGS arguments. */
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 46d8373..75e19a7 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -831,6 +831,7 @@ gimple gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL);
gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
gimple gimple_build_call (tree, unsigned, ...);
+gimple gimple_build_call_valist (tree, unsigned, va_list);
gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
gimple gimple_build_call_internal_vec (enum internal_fn, VEC(tree, heap) *);
gimple gimple_build_call_from_tree (tree);
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 7741db8..05abaa5 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
diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h
index 778f650..86e22e6 100644
--- a/gcc/tree-ssa-propagate.h
+++ b/gcc/tree-ssa-propagate.h
@@ -1,6 +1,7 @@
/* Data structures and function declarations for the SSA value propagation
engine.
- Copyright (C) 2004, 2005, 2007, 2008, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2007, 2008, 2010, 2011
+ Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC.
@@ -72,6 +73,7 @@ typedef tree (*ssa_prop_get_value_fn) (tree);
void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
bool valid_gimple_rhs_p (tree);
void move_ssa_defining_stmt_for_defs (gimple, gimple);
+bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
bool update_call_from_tree (gimple_stmt_iterator *, tree);
bool stmt_makes_single_store (gimple);
bool substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn, bool);