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
This commit is contained in:
Jakub Jelinek 2011-09-26 18:19:55 +02:00 committed by Jakub Jelinek
parent 12b03642cb
commit 2186081438
6 changed files with 78 additions and 17 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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. */

View File

@ -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);

View File

@ -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

View File

@ -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);