Commit 21860814 by Jakub Jelinek Committed by Jakub Jelinek

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
parent 12b03642
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> 2011-09-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50472 PR tree-optimization/50472
...@@ -551,6 +551,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr) ...@@ -551,6 +551,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
reaching_vuse = gimple_vuse (stmt); reaching_vuse = gimple_vuse (stmt);
push_gimplify_context (&gctx); push_gimplify_context (&gctx);
gctx.into_ssa = gimple_in_ssa_p (cfun);
if (lhs == NULL_TREE) if (lhs == NULL_TREE)
{ {
......
...@@ -215,9 +215,10 @@ gimple_call_reset_alias_info (gimple s) ...@@ -215,9 +215,10 @@ gimple_call_reset_alias_info (gimple s)
pt_solution_reset (gimple_call_clobber_set (s)); pt_solution_reset (gimple_call_clobber_set (s));
} }
/* Helper for gimple_build_call, gimple_build_call_vec and /* Helper for gimple_build_call, gimple_build_call_valist,
gimple_build_call_from_tree. Build the basic components of a gimple_build_call_vec and gimple_build_call_from_tree. Build the basic
GIMPLE_CALL statement to function FN with NARGS arguments. */ components of a GIMPLE_CALL statement to function FN with NARGS
arguments. */
static inline gimple static inline gimple
gimple_build_call_1 (tree fn, unsigned nargs) gimple_build_call_1 (tree fn, unsigned nargs)
...@@ -272,6 +273,26 @@ gimple_build_call (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. /* Helper for gimple_build_call_internal and gimple_build_call_internal_vec.
Build the basic components of a GIMPLE_CALL statement to internal Build the basic components of a GIMPLE_CALL statement to internal
function FN with NARGS arguments. */ function FN with NARGS arguments. */
......
...@@ -831,6 +831,7 @@ gimple gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL); ...@@ -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_vec (tree, VEC(tree, heap) *);
gimple gimple_build_call (tree, unsigned, ...); 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 (enum internal_fn, unsigned, ...);
gimple gimple_build_call_internal_vec (enum internal_fn, VEC(tree, heap) *); gimple gimple_build_call_internal_vec (enum internal_fn, VEC(tree, heap) *);
gimple gimple_build_call_from_tree (tree); gimple gimple_build_call_from_tree (tree);
......
/* Generic SSA value propagation engine. /* 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. Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com> Contributed by Diego Novillo <dnovillo@redhat.com>
...@@ -673,6 +673,40 @@ move_ssa_defining_stmt_for_defs (gimple new_stmt, gimple old_stmt) ...@@ -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 /* 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 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) ...@@ -689,14 +723,8 @@ move_ssa_defining_stmt_for_defs (gimple new_stmt, gimple old_stmt)
bool bool
update_call_from_tree (gimple_stmt_iterator *si_p, tree expr) update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
{ {
tree lhs;
gimple stmt = gsi_stmt (*si_p); gimple stmt = gsi_stmt (*si_p);
gcc_assert (is_gimple_call (stmt));
lhs = gimple_call_lhs (stmt);
if (valid_gimple_call_p (expr)) if (valid_gimple_call_p (expr))
{ {
/* The call has simplified to another call. */ /* The call has simplified to another call. */
...@@ -716,18 +744,14 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr) ...@@ -716,18 +744,14 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
} }
new_stmt = gimple_build_call_vec (fn, args); new_stmt = gimple_build_call_vec (fn, args);
gimple_call_set_lhs (new_stmt, lhs); finish_update_gimple_call (si_p, new_stmt, 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));
gsi_replace (si_p, new_stmt, false);
VEC_free (tree, heap, args); VEC_free (tree, heap, args);
return true; return true;
} }
else if (valid_gimple_rhs_p (expr)) else if (valid_gimple_rhs_p (expr))
{ {
tree lhs = gimple_call_lhs (stmt);
gimple new_stmt; gimple new_stmt;
/* The call has simplified to an expression /* The call has simplified to an expression
......
/* Data structures and function declarations for the SSA value propagation /* Data structures and function declarations for the SSA value propagation
engine. 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> Contributed by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC. This file is part of GCC.
...@@ -72,6 +73,7 @@ typedef tree (*ssa_prop_get_value_fn) (tree); ...@@ -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); void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
bool valid_gimple_rhs_p (tree); bool valid_gimple_rhs_p (tree);
void move_ssa_defining_stmt_for_defs (gimple, gimple); 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 update_call_from_tree (gimple_stmt_iterator *, tree);
bool stmt_makes_single_store (gimple); bool stmt_makes_single_store (gimple);
bool substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn, bool); bool substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn, bool);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment